GROUP BY's on 3 tables in one SELECT?
- From: Martin S. <Martin S.@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 18 Aug 2005 12:51:03 -0700
Hi there, I'd like to ask you for help with following:
having 3 tables:
T1 (Person_ID, Product_ID, Costs)
T2 (Person_ID, Product_ID, Balancies)
T3 (Product_ID, Product_Type)
I have simple GROUP BY query:
SELECT T1.Person_ID, T1.Product_ID, MAX(Costs)
FROM T1, T2
WHERE (T1.Product_ID = T3.Product_ID) AND (T3.Product_Type='AA')
GROUP BY T1.Person_ID, T1.Product_ID
at the end of each row obtained from previous statement, I'd like to add
sum of T2.Balancies for which (T1.Person_ID = T2.Person_ID) AND
(T2.Product_ID = T3.Product_ID) AND (T3.Product_Type='BB')
Is it possible to do it within one SELECT statement?
.
- Follow-Ups:
- Re: GROUP BY's on 3 tables in one SELECT?
- From: Hugo Kornelis
- Re: GROUP BY's on 3 tables in one SELECT?
- Prev by Date: RE: Having a stored procedure copy tables & also preserve indexing
- Next by Date: Re: GROUP BY's on 3 tables in one SELECT?
- Previous by thread: Having a stored procedure copy tables & also preserve indexing/sch
- Next by thread: Re: GROUP BY's on 3 tables in one SELECT?
- Index(es):
Relevant Pages
|
|