Subject | nested union with group by |
---|---|
Author | maria_ana_ph |
Post date | 2002-04-15T07:54:54Z |
hello!
would it be possible for the result set of a nested "union" statement
be used with "group by" statement?
here's a generalized form of my query:
select field1, field2, SUM(field3), SUM(field4)
from table1 A, table2 J
where A.field1 = J.field1
and A.field2 IN ('a', 'b','c','d', 'e', 'f', 'g')
AND A.field1 in
(select field1
FROM table1 A, table2 J, table3
WHERE A.field1 = J.field2
AND table3.field5 = J.field5
AND J.field6 = 'AP'
AND APV.field7 >= '<Date>'
UNION
select field1
FROM table1 A, table2 J, table3
WHERE A.field1 = J.field2
AND table3.field2 = J.field3
AND J.field2 = 'AR'
AND table3.field4 >= '<Date>')
GROUP BY field2, field3
if not, any idea how would i go about it?
thanks in advance!
Maan 8)
would it be possible for the result set of a nested "union" statement
be used with "group by" statement?
here's a generalized form of my query:
select field1, field2, SUM(field3), SUM(field4)
from table1 A, table2 J
where A.field1 = J.field1
and A.field2 IN ('a', 'b','c','d', 'e', 'f', 'g')
AND A.field1 in
(select field1
FROM table1 A, table2 J, table3
WHERE A.field1 = J.field2
AND table3.field5 = J.field5
AND J.field6 = 'AP'
AND APV.field7 >= '<Date>'
UNION
select field1
FROM table1 A, table2 J, table3
WHERE A.field1 = J.field2
AND table3.field2 = J.field3
AND J.field2 = 'AR'
AND table3.field4 >= '<Date>')
GROUP BY field2, field3
if not, any idea how would i go about it?
thanks in advance!
Maan 8)