thmsjlmnt3953
Registered User.
- Local time
- Today, 23:43
- Joined
- May 20, 2014
- Messages
- 120
Hi,
I am trying to run a query to count orders and sum qty from salesdetail and salesheader tables (count on header and sum of qty in detail) however it seems to be counting all the detail too?
It leads me to believe I need to subquery and join however not sure how?
I am trying to run a query to count orders and sum qty from salesdetail and salesheader tables (count on header and sum of qty in detail) however it seems to be counting all the detail too?
It leads me to believe I need to subquery and join however not sure how?
Code:
SELECT public_salesheader.[invdate] AS [date], [cust] & "/" & [del] AS customer, Count(public_salesdetail.[qty]) AS orders, Sum(public_salesdetail.[qty]) AS items
FROM public_salesdetail INNER JOIN public_salesheader ON public_salesdetail.orderno = public_salesheader.orderno
WHERE (((public_salesheader.invdate)>=Date()-30))
GROUP BY public_salesheader.[invdate], [cust] & "/" & [del]
ORDER BY public_salesheader.[invdate], Count(public_salesdetail.[qty]) DESC;