Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a Article table...The user post the articles in different category by their Email id..
i need to take a following information from that table...

Unique Emailid and how many post(count of total post)done through that emailid, category, No of posts in each category.....

I need to select all unique emailid with above informations....

Fields in ArticleTB :
Title, description, Categoryid, EmailId, PostedDate
Posted
Updated 18-Jul-14 17:44pm
v2
Comments
Dilan Shaminda 19-Jul-14 0:20am    
have you tried anything? Or any error in your query?
SnvMohan 19-Jul-14 2:21am    
I tried this for getting unique Email but cant get other information as i needed...

select Distinct Email from ArticleTB

As per your requirement, if you want all this data in single query then thats not possible. Reason behind this is,
You first of all need unique email id and lastly you said that you want 'No of posts in each category', that nothing but your finding unique category. Logically and naturally two unique things can not be added to same row. Even that possible if there single category or single email id.

please let me know if you understand this or any other help you need.
 
Share this answer
 
SELECT Title, EmailId,Count(EmailId) as totalads
FROM dbo.ArticleTB
where PostedDate > DATEADD(dd, -2, GETDATE()) AND PostedOn < DATEADD(dd, -1, GETDATE())
GROUP BY EmailId,Title;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900