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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 GROUP BY Question

Author  Topic 

bkren
Starting Member

1 Post

Posted - 2007-07-02 : 14:12:51
Here is the Statement that successfully reports to me last weeks sales.

SELECT Sum(crdtamnt-debitamt).

FROM SBM01.dbo.gl00100 gl00100, SBM01.dbo.GL20000 GL20000

WHERE GL20000.ACTINDX = gl00100.ACTINDX
AND ((gl00100.ACCATNUM=31)) and (gl20000.OPENYEAR=2007)
AND (gl00100.PSTNGTYP=1)
AND (datepart(week,(trxdate)) = (datepart(week,CURRENT_TIMESTAMP) -1))

GROUP BY day(trxdate)
ORDER BY day(trxdate)

Heres the PROBLEM:

If Zero sales on Sunday then it only reports 5 days worth of sales.

Is there any way to get it to return 0 for Sunday in the case there is no Sunday sales?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-07-02 : 15:17:46
Perhaps you can set a default value of 0 to the column so this is taken care of?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -