Hello,
I hope someone can help me.
I have a table. For example's sake, it has 4 columns.
In actuality, it has 15.
The structure is
Date smalldatetime (Primary Key)
Total1 money
Total2 money
Total3 money
(table actually has 14 different "Total" columns)
The Date column will always be the last day of the month
and only 1 record will ever have that date.
For example:
Date Total1 Total2 Total3
3/31/2003 10.00 20.00 30.00
4/30/2003 100.00 200.00 300.00
5/31/2003 400.00 500.00 600.00
My question is how do I retrieve a given month's and the previous month's figures into one record using an SQL statement.
For example what I need for May 2003 is:
Date Tot1 Tot2 Tot3 PTot1 PTot2 PTot3
5/31/2003 400.00 500.00 600.00 100.00 200.00 300.00
The "Tot" columns are from May and the "Ptot" columns are from April.
I'm trying to avoid imbedding a SELECT statement for each previous month's column since I actually have 14 "total" columns and a SELECT statment for each one would be quite cumbersome.
Thank you for any suggestions.
I hope someone can help me.
I have a table. For example's sake, it has 4 columns.
In actuality, it has 15.
The structure is
Date smalldatetime (Primary Key)
Total1 money
Total2 money
Total3 money
(table actually has 14 different "Total" columns)
The Date column will always be the last day of the month
and only 1 record will ever have that date.
For example:
Date Total1 Total2 Total3
3/31/2003 10.00 20.00 30.00
4/30/2003 100.00 200.00 300.00
5/31/2003 400.00 500.00 600.00
My question is how do I retrieve a given month's and the previous month's figures into one record using an SQL statement.
For example what I need for May 2003 is:
Date Tot1 Tot2 Tot3 PTot1 PTot2 PTot3
5/31/2003 400.00 500.00 600.00 100.00 200.00 300.00
The "Tot" columns are from May and the "Ptot" columns are from April.
I'm trying to avoid imbedding a SELECT statement for each previous month's column since I actually have 14 "total" columns and a SELECT statment for each one would be quite cumbersome.
Thank you for any suggestions.