Help with a subquery

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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.
 

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

Back
Top