SQL to recieve subtotals

  • Thread starter Thread starter Kar
  • Start date Start date
K

Kar

Hello,
I'm trying to put together the SQL to recieve subtotals
per employee AND that subtotal divided into subtotals per
product. The problem could be applied to Northwind
(Employees, Orders, Order Details).
Can anyone give me a hint on how to get two subtotal
levels?
Tia,
Kar
 
Hi Kar,

How about the query?

SELECT employeeid, ProductID, sum(salesquantity) AS salesout
From
(SELECT employeeid, a.ProductID, a.UnitPrice*a.Quantity AS salesquantity
FROM [Order details] AS a INNER JOIN orders AS p ON a.Orderid=p.Orderid)
GROUP BY employeeid, ProductID;

Please feel free to reply to the threads if you have any questions or
concerns.


Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| X-Tomcat-NG: microsoft.public.access.adp.sqlserver
|
| Hello,
| I'm trying to put together the SQL to recieve subtotals
| per employee AND that subtotal divided into subtotals per
| product. The problem could be applied to Northwind
| (Employees, Orders, Order Details).
| Can anyone give me a hint on how to get two subtotal
| levels?
| Tia,
| Kar
|
 
Back
Top