OldSlowDog
Programmer
Hello,
Here is the query I am runnin in SQL 2000.
SELECT convert(char(10), CloseDate, 101) as Date,
Cinema1 = SUM(CASE WHEN Loc =1 THEN TicketSales END),
Cinema2 = SUM(CASE WHEN Loc =2 THEN TicketSales END),
Cinema3 = SUM(CASE WHEN Loc =3 THEN TicketSales END)
FROM TicketSales_tbl
Where CloseDate > '3/1/2008' and CloseDate < '4/1/2008'
GROUP BY CloseDate
ORDER BY CloseDate
The result is:
Date Cinema1 Cinema2 Cinema3
3/1/2008 27 39 41
3/2/2008 24 31 33
3/3/2008 18 22 27
What I like to have are the vertical and horizontal totals:
Date Cinema1 Cinema2 Cinema3 Daily
3/1/2008 27 39 41 107
3/2/2008 24 31 33 88
3/3/2008 18 22 27 67
Monthly 69 92 101 262
Would you show me how to go about getting the totals?
And, if I want to have the results stored in a table do I place an INSERT at the beginning of the sql statement?
Thank you for helping in advance.
Here is the query I am runnin in SQL 2000.
SELECT convert(char(10), CloseDate, 101) as Date,
Cinema1 = SUM(CASE WHEN Loc =1 THEN TicketSales END),
Cinema2 = SUM(CASE WHEN Loc =2 THEN TicketSales END),
Cinema3 = SUM(CASE WHEN Loc =3 THEN TicketSales END)
FROM TicketSales_tbl
Where CloseDate > '3/1/2008' and CloseDate < '4/1/2008'
GROUP BY CloseDate
ORDER BY CloseDate
The result is:
Date Cinema1 Cinema2 Cinema3
3/1/2008 27 39 41
3/2/2008 24 31 33
3/3/2008 18 22 27
What I like to have are the vertical and horizontal totals:
Date Cinema1 Cinema2 Cinema3 Daily
3/1/2008 27 39 41 107
3/2/2008 24 31 33 88
3/3/2008 18 22 27 67
Monthly 69 92 101 262
Would you show me how to go about getting the totals?
And, if I want to have the results stored in a table do I place an INSERT at the beginning of the sql statement?
Thank you for helping in advance.