At 11:10 PM 8/2/2006, Peter Brawley wrote:
>Barry
>
> >It would make life easier if I could also show a column
> >with the cumulative count for each month.
>
>Set @cum - 0;
>Select
> Monthname(DatePaid) Month,
> Year(DatePaid) Year,
> Count(*) as Registrations,
> Extract(Year_Month from DatePaid) AS Monindex,
> @cum := @cum + Count(*) AS 'Year to date'
> >From capclave2005reg
>Where year(DatePaid)=2004 and (amount > 0 or Dealer = 'Y')
>Group by Monindex ;
>
>PB
Looked promising, but gets me the following, which isn't quite right:
+-----------+------+---------------+----------+--------------+
| Month | Year | Registrations | Monindex | Year to date |
+-----------+------+---------------+----------+--------------+
| October | 2004 | 23 | 200410 | 23 |
| December | 2004 | 5 | 200412 | 5 |
| January | 2005 | 9 | 200501 | 14 |
| February | 2005 | 11 | 200502 | 16 |
| April | 2005 | 2 | 200504 | 7 |
| May | 2005 | 48 | 200505 | 53 |
| June | 2005 | 45 | 200506 | 50 |
| July | 2005 | 10 | 200507 | 15 |
| August | 2005 | 17 | 200508 | 22 |
| September | 2005 | 58 | 200509 | 63 |
| October | 2005 | 97 | 200510 | 102 |
+-----------+------+---------------+----------+--------------+
Barry