Re: Running totals on a select count statement
From: zack (anonymous_at_discussions.microsoft.com)
Date: 03/10/04
- Next message: Vishal Parkar: "Re: More help with query"
- Previous message: Steve Kass: "Re: Running totals on a select count statement"
- In reply to: Steve Kass: "Re: Running totals on a select count statement"
- Next in thread: Steve Kass: "Re: Running totals on a select count statement"
- Reply: Steve Kass: "Re: Running totals on a select count statement"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 10 Mar 2004 11:46:08 -0800
Steve,
Im almost there but Im running into a problem with things being out of order. Here is what I have so far:
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 convert(Char(10), AR2.Creation_Date, 101) <= 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)
returns:
11/10/2003 1 32
11/11/2003 4 36
11/13/2003 1 37
12/18/2003 1 38
12/22/2003 1 39
12/23/2003 6 45
12/24/2003 2 47
12/30/2003 3 50
01/12/2004 9 9
01/29/2004 3 12
01/30/2004 1 13
02/06/2004 1 14
02/10/2004 3 17
02/24/2004 2 19
03/04/2004 11 30
03/05/2004 1 31
Whats happening is that the ordering is lost in the subquery and I can not specify an order by clause in the sub query. When I order the outside sql correctly the count is then incorrect. Any thoughts????? Possible a different date function.
- Next message: Vishal Parkar: "Re: More help with query"
- Previous message: Steve Kass: "Re: Running totals on a select count statement"
- In reply to: Steve Kass: "Re: Running totals on a select count statement"
- Next in thread: Steve Kass: "Re: Running totals on a select count statement"
- Reply: Steve Kass: "Re: Running totals on a select count statement"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|