Main Body
SELECT
Employee.[Employee ID]
,Employee.[Last Name]
,Employee.[First Name]
,Orders.[Order ID]
,Orders.[Employee ID]
,Orders.[Order Date]
,Orders_Detail.[Unit Price]
,Orders_Detail.Quantity
,Product.[Product ID]
,Product.[Product Name]
,Product.[Product Type ID]
,Product.[Product Class]
,Product_Type.[Product Type Name]
FROM
Xtreme115DB.dbo.Orders
INNER JOIN [Xtreme115DB.dbo.Orders Detail] Orders_Detail ON Xtreme115DB.dbo.Orders.[Order ID] = Orders_Detail.[Order ID]
INNER JOIN Xtreme115DB.dbo.Employee ON Xtreme115DB.dbo.Orders.[Employee ID] = Xtreme115DB.dbo.Employee.[Employee ID]
INNER JOIN Xtreme115DB.dbo.Product ON Orders_Detail.[Product ID] = Xtreme115DB.dbo.Product.[Product ID]
INNER JOIN [Xtreme115DB.dbo.Product Type] Product_Type ON Xtreme115DB.dbo.Product.[Product Type ID] = Product_Type.[Product Type ID]
WHERE
Orders.[Order Date] in Date (2003, 01, 01) to Date (2003, 03, 31)
ORDER BY
@Quarter ASC -- Group #1
,SUM(@amount,Employee.[Last Name]) DESC
,Product.[Product Class] ASC -- Group #3
,Product_Type.[Product Type Name] ASC -- Group #4
,Product.[Product Name] ASC -- Group #5
subsales.rpt
SELECT
Employee.[Employee ID]
,Employee.[Last Name]
,Employee.[First Name]
,Orders.[Order ID]
,Orders.[Order Amount]
,Orders.[Employee ID]
,Orders.[Order Date]
,Orders_Detail.[Unit Price]
,Orders_Detail.Quantity
,Product.[Product ID]
,Product.[Product Class]
FROM
Xtreme115DB.dbo.Orders
INNER JOIN Xtreme115DB.dbo.Employee ON Xtreme115DB.dbo.Orders.[Employee ID] = Xtreme115DB.dbo.Employee.[Employee ID]
INNER JOIN [Xtreme115DB.dbo.Orders Detail] Orders_Detail ON Xtreme115DB.dbo.Orders.[Order ID] = Orders_Detail.[Order ID]
INNER JOIN Xtreme115DB.dbo.Product ON Orders_Detail.[Product ID] = Xtreme115DB.dbo.Product.[Product ID]
WHERE
Orders.[Order Date] in Date (2003, 01, 01) to Date (2003, 03, 31) and
Orders.[Order Amount]>0 and
Employee.[Last Name] = {?Pm-Employee.Last Name} and
Employee.[First Name] = {?Pm-Employee.First Name}
ORDER BY
@MyName ASC -- Group #1
,Orders.[Order Date] ASC -- Group #2