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 |
|
abcd
Yak Posting Veteran
92 Posts |
Posted - 2008-11-28 : 02:00:36
|
| my problem is as follows....i am having a result set containing columnsuserid,deptname,leavetype,ismispunched, where leave type can be of three categoriesnormal,on duty and on tour now i want to display userid,deptname and in seperate columns how many times user went on -on duty,normal or was on tour basically problem is how to compare column value in a table with a given criteria and display it in a seperate column |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-11-28 : 03:02:43
|
| SUM(CASE leave WHEN 'normal' THEN 1 END 0 END) AS TotalNormalLeaveRepeat for the the other two and then group by userid,deptname--Gail ShawSQL Server MVP |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-28 : 05:44:21
|
| http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=115041 |
 |
|
|
|
|
|