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 |
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-08-22 : 04:42:25
|
| Thanks for reading and the continued help.I have a table structured - Trans--------DeltaCashCorrection---100Dep----------50Correction----0Correction---50etc . .I would like to count all Corrections where DeltaCash column is greater than 0.For the data shown 2.Thanks in advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-22 : 04:46:01
|
| [code]SELECT COUNT(CASE WHEN Trans='Correction' AND DeltaCash > 0 THEN 1 ELSE NULL END) AS CntValue,.....FROM Table[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-22 : 04:48:54
|
[code]select count(*)from yourtablewhere Trans = 'Correction'and DeltaCash > 0[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-08-22 : 04:53:44
|
| Works as expected thanks I was basically there just got some syntax wrong. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-22 : 04:56:59
|
np...you're welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|