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 |
|
jfm
Posting Yak Master
145 Posts |
Posted - 2012-06-06 : 11:29:51
|
| Hi there, I don't know how to finish this query: SELECT day_column, SUM(parking_balance) AS parkingSUM(CASE WHEN INT(Personal_balance / 30.5 = 0) THEN parking_balance END) as '0'FROM My_FileGROUP BY day_columnORDER BY day_columnThe query works without using INT. I really need to do 'Personal_balance/30.5' Any idea?Thanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-06 : 11:34:46
|
| CASE WHEN convert(INT,Personal_balance / 30.5) = 0 THEN parking_balance ENDOnly include when Personal_balance / 30.5I would addCASE WHEN convert(INT,Personal_balance / 30.5) = 0 THEN parking_balance else 0 ENDto avoid the null warning in the sum==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-06-06 : 11:44:58
|
| CASE WHEN Personal_balance < 30.5 THEN parking_balance else 0 ENDJimEveryday I learn something that somebody else already knew |
 |
|
|
jfm
Posting Yak Master
145 Posts |
Posted - 2012-06-06 : 11:49:13
|
| Perfect! Thanks a lot! |
 |
|
|
|
|
|