Re: Running totals on a select count statement

From: zack (anonymous_at_discussions.microsoft.com)
Date: 03/11/04


Date: Thu, 11 Mar 2004 06:26:06 -0800

Steve,

After rereading you last message I think I got it to work correctly by replacing:
"where convert(Char(10), AR2.Creation_Date, 101) <= convert(Char(10), AR.Creation_Date, 101)" with
"where AR2.Creation_Date<= convert(Char(10), AR.Creation_Date, 101)"

Working select=>
SELECT convert(Char(10), AR.Creation_Date, 101) AS DateWritten, COUNT(AR.Creation_Date) AS Written,
        (
                Select count(AR2.Creation_Date) from dbo.vw_Nothing AR2
                where AR2.Creation_Date<= convert(Char(10), AR.Creation_Date, 101)
        )
        as RunningTotal
FROM dbo.vw_Nothing AR
GROUP BY DATEPART(yy, AR.Creation_Date), DATEPART(mm, AR.Creation_Date), DATEPART(dd, AR.Creation_Date), CONVERT(Char(10), AR.Creation_Date, 101)