Download Informix Guide to SQL: Tutorial, Version 6.0

Transcript
Set Operations
If you include an ORDER BY clause, it must follow Query 3-36 and use an
integer, not an identifier, to refer to the ordering column. Ordering takes place
after the set operation is complete.
SELECT DISTINCT stock_num, manu_code
FROM stock
WHERE unit_price < 25.00
UNION
SELECT stock_num, manu_code
FROM items
WHERE quantity > 3
ORDER BY 2
Query 3-37
The compound query in Query 3-37 selects the same rows as Query 3-36 but
displays them in order of manufacturer code, as shown in Query Result 3-37:
stock_num manu_code
5
9
302
301
302
201
5
103
106
5
ANZ
ANZ
HRO
KAR
KAR
NKL
NRG
PRC
PRC
SMT
Query Result 3-37
Composing Advanced SELECT Statements 3-45