Need help counting records by date

G

Guest

Please help. I have an Orders table with Ord#, ReceivedDt, ShipDt and I need
a query that will summarize activity by date.
Sample data:
Ord# Recv Ship
0001 10/10/07 10/13/07
0002 10/12/07 10/12/07
0003 10/12/07 10/13/07

Output summary needs to count activity by date as follows
Date Received Shipped
10/10 1 0
10/12 2 1
10/13 0 2

Your assistance will be greatly appreciated.
 
G

Guest

There probably is an easier way but these three queries will do it.
OrderDate ---
SELECT JamesCook.Recv AS OrderDate
FROM JamesCook
UNION SELECT JamesCook.Ship AS OrderDate
FROM JamesCook;

JamesCookAll ---
SELECT OrderDate.OrderDate, JamesCook.[Ord#], "Recv" AS RecvShip
FROM OrderDate INNER JOIN JamesCook ON OrderDate.OrderDate = JamesCook.Recv
UNION ALL SELECT OrderDate.OrderDate, JamesCook.[Ord#], "Ship" AS RecvShip
FROM OrderDate INNER JOIN JamesCook ON OrderDate.OrderDate = JamesCook.Ship;

TRANSFORM Count(JamesCookAll.[Ord#]) AS [CountOfOrd#]
SELECT JamesCookAll.OrderDate, Count(JamesCookAll.[Ord#]) AS [Total Of Ord#]
FROM JamesCookAll
GROUP BY JamesCookAll.OrderDate
PIVOT JamesCookAll.RecvShip;
 

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