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 |
TCB
Starting Member
1 Post |
Posted - 2014-11-20 : 13:52:57
|
How do I add the bottom line to my statement?SELECTAgentID,PaymentAmountFROM Table AWHERE DATEOFPAYMENT GROUP BY CollectorNumberORDER BY CollectorNumber,LastName,DateofPayment,PaymentAmount----------------------------------------------------------------------------------------------if DATEOFPAYMENT = yesterday then PaymentAmount else 0 as 'previous day'orif DATEOFPAYMENT = current_Month then PaymentAmount else 0 as 'MTD'or if DATEOFPAYMENT = current_Year then PaymentAmount else 0 as 'YTD |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-20 : 14:01:03
|
CASE, not IFSELECTAgentID,PaymentAmount,CASE WHEN DATEOFPAYMENT = yesterday then PaymentAmount else 0 as 'previous day' END... |
|
|
|
|
|