>
Part | Description |
aggfunction | An SQL aggregate function that operates on the selected data. |
selectstatement | A SELECT statement. |
pivotfield | The field or expression you want to use to create column headings in the query's result set. |
value1, value2 | Fixed values used to create column headings. |
PARAMETERS [Sales for which year?] LONG;This example creates a crosstab query that returns product sales by quarter for each supplier for a user-specified year. The quarters are returned from left to right (pivoted) as columns, and the supplier names are returned from top to bottom as rows.
TRANSFORM Sum([Order Details].Quantity * ([Order Details].UnitPrice -
([Order Details].Discount / 100) * [Order Details].UnitPrice))
AS Sales SELECT ProductName FROM Orders INNER JOIN(Products
INNER JOIN [Order Details]
ON Products.ProductID = [Order Details].ProductID)
ON Orders.OrderID = [Order Details].OrderID
WHERE DatePart("yyyy", OrderDate) = [Sales for which year?]
GROUP BY ProductName ORDER BY ProductName
PIVOT DatePart("m", OrderDate);
PARAMETERS [Sales for which year?] LONG;
TRANSFORM Sum([Order Details].Quantity * ([Order Details].UnitPrice -
([Order Details].Discount / 100) * [Order Details].UnitPrice)) AS Sales
SELECT CompanyName FROM Orders
INNER JOIN ((Suppliers INNER JOIN Products
ON Suppliers.SupplierID = Products.SupplierID)
INNER JOIN [Order Details]
ON Products.ProductID = [Order Details].ProductID)
ON Orders.OrderID = [Order Details].OrderID
WHERE DatePart("yyyy", OrderDate) = [Sales for which year?]
GROUP BY CompanyName ORDER BY CompanyName
PIVOT "Qtr " & DatePart("q", OrderDate) In ('Qtr 1', 'Qtr 2', 'Qtr 3',
'Qtr 4');