| |||||||||
|
|
|
| New! Download Crosstab/Pivot Query Example Database |
Access provides a pivot query wizard which, once you get some practice you'll find it as good place to start. I usually have to go into the SQL editor and tweak the code a little. Here are the SQL statements that will produce the output we want:
TRANSFORM Sum([M_Sales].[Amount]) AS SumOfAmount
SELECT [M_Sales].[Department]
FROM M_Sales
GROUP BY [M_Sales].[Department]
PIVOT Format([M_Sales].[Sale_date],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
The key points of the query are:
1) The query's TRANSFORM statement contains the values that will be summed and displayed as the results of the query.
2) The SELECT statement will contain the Row Headings
3) The GROUP BY is just what it says 4) The PIVOT statement
will create the column headings and may be thought of as a Horizontal Group
By. Here are the results of the query:
Have errors? No doubt we can answer your question quickly and easily. Simple SQL questions get simple answers at no charge via email.
Popular Database Templates:
HOA/Homeowner
Association Database Template
|
Free SQL Tutorial & Query Solutions Workaround Runtime Examples Samples |