[AccessD] SQL: Sum from the third table

Marcus, Scott (GEAE, Contractor) scott.marcus at ae.ge.com
Wed Jul 23 08:05:00 CDT 2003


Ervin,
 
How about.
 
SELECT Customer.CustID,
             Customer.Name,
             First(Order.ValAmount) AS UkVred,
             Sum(OrderDet.Quantity) AS ukkol
FROM (Customer INNER JOIN [Order] ON Customer.CustID = Order.CustID)
           INNER JOIN OrderDet ON Order.RedBROJ = OrderDet.RedBROJ
GROUP BY Customer.CustID, Customer.Name;
 
Scott

-----Original Message-----
From: Ervin Brindza [mailto:viner at eunet.yu]
Sent: Wednesday, July 23, 2003 8:57 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] SQL: Sum from the third table


 

----- Original Message ----- 
From: Marcus,  <mailto:scott.marcus at ae.ge.com> Scott (GEAE, Contractor) 
To: 'Access Developers discussion and  <mailto:accessd at databaseadvisors.com>
problem solving' 
Sent: 23 July, 2003 1:41 PM
Subject: RE: [AccessD] SQL: Sum from the third table

Ervin,
 
SELECT Customer.CustID,
             Customer.Name,
             Sum(Order.ValAmount) AS UkVred,
             Sum(OrderDet.Quantity) AS ukkol
FROM (Customer INNER JOIN [Order] ON Customer.CustID = Order.CustID)
           INNER JOIN OrderDet ON Order.RedBROJ = OrderDet.RedBROJ
GROUP BY Customer.CustID, Customer.Name;
 
Hope this helps.
 
Scott

 
Sorry, but the same. E.g. if there are 1 order for the customer, with e.g. 3
items, the field UkVred contain 3 times the ValAmount. It's weird?
Thanks,
    Ervin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030723/5502d345/attachment-0003.html>


More information about the AccessD mailing list