Hi,
I have a table with a structure such as table(PK, a, b, c, d, e, f, g).
And I have many queries that I want to join:
select PK, sum(c) where...
JOIN
select PK, sum(e) where...
JOIN
select PK, sum(g) where ...
JOIN
select PK,a,b,d,f
Every sum(c|e|g) is actually a
select sum(c|e|g) from .... where...
because there are many conditions involved (not all c|e|g's must be added)
Is this the best way to do it? I was suggested to write it in PL / SQL, which I would have to learn. If its the way to go, i'll do it, but im not sure whats wrong with the solution shown above.
Edit
Im pretty sure its a Join. Here's what I want.
I need to get a result set in the form:
PK, a,b,COMPLEX_SUM_ON_C,d,COMPLEX_SUM_ON_D,f,COMPLEX_DUM_ON_G
so I thought of joining many queries to get this result.
Each of the COMPLEX... is another select (select sum...). This is a very big table, and writing
select a,b,(select sum..),d,(select sum...),f,(select sum...)
will yield bad performance (so I was told to remove it)
I've edited my query above.
Thanks in advance.