GROUP BY's on 3 tables in one SELECT?



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



Relevant Pages

  • Re: GROUP BYs on 3 tables in one SELECT?
    ... >T1 (Person_ID, Product_ID, Costs) ... >T2 (Person_ID, Product_ID, Balancies) ... there might be some typos in your query as well (e.g. the T2 after FROM ... I ask you to post details about your tables AS CREATE ...
    (microsoft.public.sqlserver.mseq)
  • Re: Custom displaymember in comboBox
    ... Bill ... do u know how much it costs to add ... >> can u tell me the flaws in this Query. ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: LDAP query for blank attributes?
    ... Thanks for clarification. ... > When you use a NOT operator in the query, ... it costs as much as you put it into it ... Prev by Date: ...
    (microsoft.public.windows.server.active_directory)
  • Re: LDAP query for blank attributes?
    ... When you use a NOT operator in the query, ... it costs as much as you put it into it ... I'm using the LDAP filter option ... Prev by Date: ...
    (microsoft.public.windows.server.active_directory)
  • Date query in Acceess
    ... I want to have a query that is calculating sum of the costs for each ... First, I made a query that has 3 fields: name, date and costs. ... I mean it shows the missions in the ...
    (microsoft.public.access.queries)