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 |
|
rajsrangs
Starting Member
2 Posts |
Posted - 2009-10-22 : 11:01:21
|
| Tricky function I have a table tblClaim with a field IsUserClaimed (bit field).I did need a query which would return me the count of claims grouped by the month and then the isUserClaimed field.I have the following query which lists tha data snapshotSELECT Count(ClaimId) CountClaims , Year(ClaimDate) YearOfClaim , Month(ClaimDate) MonthOfClaim, UserClaimed isUserClaimedFROM tblRefUserClaimed tRUC LEFT OUTER JOIN tblClaim tC ON tRUC.UserClaimed = tC.IsUserClaimed GROUP BY userclaimed, Year(ClaimDate), Month(ClaimDate)ORDER BY Year(ClaimDate),Month(ClaimDate), UserClaimedCount Year Month isUserClaimed863 2009 8 059 2009 8 18 2009 9 11 2009 10 06 2009 10 1However on close inspection it should include in the list the following for Month 9.Count Year Month isUserClaimed0/NULL 2009 9 0Could someone help me please?Rajesh |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-10-22 : 11:30:41
|
| Rajesh,tricky function?!? more like freaky :) Why the heck are you joining two tables on a bit field. what kind of design is that. This is new to me, never seen a table join on bit field. could this be a design issue?<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
rajsrangs
Starting Member
2 Posts |
Posted - 2009-10-22 : 11:48:24
|
| well it is a reference table / dummy. How else do I get record for each type of isUserClaimed? |
 |
|
|
|
|
|