[SQL] Group And Sort After Union

2002-08-02 Thread cnliou
generates 2 groups of data set: SELECT c11 AS c1,SUM(c12) AS c2 FROM table1 GROUP BY c1 ORDER BY c2 UNION SELECT c21 AS c1,SUM(c22) AS c2 FROM table2 GROUP BY c1 ORDER BY c2; How do I do that? Thank you in advance! CNLIOU ---(end of broadcast)--- TIP 6

[SQL] EXISTS Keyword

2001-10-03 Thread cnliou
Hello! I vaguely remember that someone said somewhere that EXISTS runs faster than IN: SELECT * FROM table1 where field1 EXISTS (SELECT field4 FROM table2) However, all I got from version 7.1.3 is: ERROR: parser: parse error at or near "exists" While below works: SELECT * FROM table1 where

[SQL] SubQuery

2001-10-03 Thread cnliou
Hi! I am using MyTable to serve the "next number" functionality like PGSQL embeded "sequence" offers. The only difference of the two is MyTable has 2 more fields - "ID" and "Starting Effective Date". The UPDATE SQL fails when I am trying to update record ID1 | 2001-08-01| 11 to