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 |
|
cool.mugil
Starting Member
32 Posts |
Posted - 2009-03-20 : 06:20:46
|
| Hi,In my table i have following fieldsID,Date,StatusI want to get the count based on the status.Which is p for present,a for absent.The scenario for status is either values will be present or absent or it will have any one.Please guide me how to write query for this.Thanks in advance. |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-20 : 06:49:31
|
| [code]select[ID],[Date],CountPresent=sum(case when status='p' then 1 else 0 end),CountAbsent= sum(case when status='a' then 1 else 0 end),fromyourtablegroup by[ID],[Date][/code] |
 |
|
|
cool.mugil
Starting Member
32 Posts |
Posted - 2009-03-20 : 07:44:47
|
| Thanks for help.It works fine. |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-20 : 07:46:56
|
| np |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-20 : 09:24:42
|
| does date field contain timepart also? |
 |
|
|
|
|
|