SQL to recieve subtotals

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
 
A

Alick [MSFT]

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
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top