Re: [SQL] Group And Sort After Union

2002-08-02 Thread Tom Lane
[EMAIL PROTECTED] (cnliou) writes: > I want to GROUP BY and ORDER BY on the result of UNION similar to the > following (wrong) SQL: > (SELECT c11 AS c1,SUM(c12) AS c2 FROM table1 > UNION > SELECT c21 AS c1,SUM(c22) AS c2 FROM table2 > ) > GROUP BY c1 > ORDER BY c2; Correct is SELECT * FROM (SEL

[SQL] Group And Sort After Union

2002-08-02 Thread cnliou
Greetings! I want to GROUP BY and ORDER BY on the result of UNION similar to the following (wrong) SQL: (SELECT c11 AS c1,SUM(c12) AS c2 FROM table1 UNION SELECT c21 AS c1,SUM(c22) AS c2 FROM table2 ) GROUP BY c1 ORDER BY c2; Please note that the following is NOT what I want because it generate