I need to do two counts of a column based on the content of another column in a different table.
SELECT WMTRANSACTIONHEADER.TRANSACTIONTYPE
, IMITEM.ITEMSUPCCODE
, COUNT(IMITEM.ITEMSUPCCODE) AS 'Shipment'
, COUNT(IMITEM.ITEMSUPCCODE) AS 'Reciept'
, CAST(MTRANSACTIONHEADER.TRANSACTIONDATE AS DATE) AS DATE
FROM WMTRANSACTIONHEADER
INNER JOIN WMTRANSACTIONDETAIL ON WMTRANSACTIONHEADER.ROWID = WMTRANSACTIONDETAIL.R_TRANSACTIONHEADER
INNER JOIN IMITEM ON WMTRANSACTIONDETAIL.R_ITEM = IMITEM.ROWID
Forgive me for how unreadable it is, but generally, I'm trying to count ITEMSUPCCODE based on whether TRANSACTIONTYPE is either an 'R' or an 'S'. Any tips/ideas would be great!
EDIT:
Unfortunately I underestimated this task and the importance of other fields. So let me explain this more in depth. I am making a report that counts the daily ITEMSUPCCODE fields. There are 8 ITEMSUPCCODE fields that are possible, and we want a count of each one. So the perfect report would group all the transactions in a day, then group by each entry in ITEMSUPCCODE, and then count each entry in ITEMSUPCCODE, based on what is in TRANSACTIONTYPE. I apologize for not being clear, I thought the counting part was the only issue I had!