Help with a subquery

J

Jean-Marie

Hello!
I am beginning with subqueries and need some help with this exercise. Say I
have 2 tables, tblSales (SaleID, DateSale, ClientSale) and
tblSalesDetails(SalesDetailID, ProductSdt, QtySdt)
I want to build a query that results in something similar to this:
Client1 Amount1
Client2 Amount2
Clinet3 Amount3
Where Amounti is the total amount sold to clienti. I am trying to obtain
these amounts via a subquery; I know it ca be done otherwise but I am
practicing. Can someone help me with this?
Many thanks in advance.
 
O

Ofer Cohen

Create a group by query that link the two tables using the SaleID (which I
assume is the common field for both tables), and sum the quantity

Something like

SELECT tblSales.ClientSale, Sum(tblSalesDetails.QtySdt) AS SumOfQtySdt
FROM tblSales INNER JOIN tblSalesDetails ON tblSales.SaleID =
tblSalesDetails.SalesDetailID
GROUP BY tblSales.ClientSale
 
J

Jean-Marie

Thanks very much and sorry for the delay in replying. i wao out for a trip
and could not check the newsgroup.
This works fine. However I still need some good resource to learn
subqueries. Any idea is welcome.
Thanks again.
 
Top