Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
latif_qau
Starting Member
4 Posts |
Posted - 2010-06-24 : 20:11:51
|
| HiI have Four tables Calender, Authors, Articles, comments.i want to create a report showing following statsdate AuthorId TotalArticles TotalComments1/12/2009 8 2 01/13/2009 4 2 31/14/2009 5 0 01/15/2009 6 2 31/16/2009 7 0 0 Calender Table has just date given above.Articles has date_created, article_id , author_id, Comments has date_created, comments_id, article_idThanks in advance...Khan |
|
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2010-06-25 : 01:36:14
|
your code my differ based on which date you want to define in your report.if you take date from articles or date from comments it will surely show you different results.i'll just write you a sample and you change the desired date or. change the connection between the dates (using left join on the tables or making connection with date by articles.date_created and comments.date_created). all this things will affect your output, unfortunatelly i don't know your bussines process.selectc.Date as date,a.Author_id as AuthorId,count(distinct a.article_id) as TotalArticles,count(distinct com.comments_id) as TotalCommentsfrom Calender as cinner join Articles as aon c.date = a.date_createdinner join Comments as comon com.article_id = a.article_idgroup by c.Dateorder by c.Date |
 |
|
|
latif_qau
Starting Member
4 Posts |
Posted - 2010-06-27 : 13:34:33
|
| Thanks slimt i am trying it.....Khan |
 |
|
|
latif_qau
Starting Member
4 Posts |
Posted - 2010-06-27 : 13:56:43
|
| my main purpose is on date 01/01/2010 which authors post how many articles and how many commets he recieve on that date on all of his articles.if i have three authors with id 1 2, 3then first few lines will look like date AuthorId TotalArticles TotalCommentsOnAllArticles1/01/2010 1 2 01/01/2010 2 0 121/01/2010 3 3 1Khan |
 |
|
|
latif_qau
Starting Member
4 Posts |
Posted - 2010-06-27 : 15:07:58
|
| @slimtThanks alot for your help after a samll change it works. selectc.Date as date,a.Author_id as AuthorId,count(distinct a.article_id) as TotalArticles,count(distinct com.comments_id) as TotalCommentsfrom Calender as cinner join Articles as aon c.date = a.date_createdleft join Comments as comon com.article_id = a.article_idgroup by c.Date , a.Author_idorder by c.DateKhan |
 |
|
|
|
|
|
|
|