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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-26 : 07:38:53
|
| Balaji writes "I need to count records which are not existing. Let me say I have a table with "ID,date,comment" columns. There may be any number of comments logged on any day. There may be no comments logged on some days. I need to display a summary of no. of comments logged on each day from xx-xxx-xxxx to yy-yyy-yyyy. I guess you understood it." |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-09-26 : 07:40:24
|
Well, you can't count records that don't exist. What you're asking for is a way to display a date that might not have any corresponding rows, the technique used in this article can help you:http://www.sqlteam.com/item.asp?ItemID=3332 |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-26 : 07:57:11
|
| Select Count(1),Date From tablename where Date between todate and fromdate group by DateChirag |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-26 : 08:32:14
|
| Make use of the F_TABLE_DATE function written by Michael Valentine Jones, here on SQLTeam.Peter LarssonHelsingborg, Sweden |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-09-27 : 04:35:44
|
| if u have master table for such comments and transaction tables, u can use NOT IN in ur query, say:select <comment> from <comment master> where <comment id> not in <select comment id from transaction>here u will get the comments, Mahesh |
 |
|
|
|
|
|