91
10 Axel 30 High o 10/04/
Shu paytgacha UNION kalit so‟zi yordamida birlashtirilgan so'rov
natijalari qanday tartibda matnga chiqarilishi to'g‟risida gapirmadik.
Birlashtirilgan
natijalarni ORDER
BY
kalit so'zi yordamida
tartiblashtirish mumkin. Yoqoridagi misolni tartub raqamlariga nisbatan
tartiblashni ko'rib o'tamiz.
SELECT a.snum, sname, onum, ‟Highest on‟, odate FROM Salespeople
a. Orders b WHERE a.snum = b.snum AND b.amt = (SELECT MAX
(amt) FROM Orders с WHERE c.odate = b.odate)
UNION
SELECT a.snum, sname, onum. ‟Lowest on‟, odate F ROM Salespeople
a. Orders b WHERE a.snum = b.snu AND b.amt = (SELECT MIN (amt)
FROM Orders с WHERE c.odate = b.odate) ORDER BY 3; Natija
quyidagicha:
1007 Rifkin
3001
Lowest on
10/03/199
1002 Serres
3005
Highest on
10/03/199
1002 Serres
3007
lowest on
10/04/199
1001 Peel
3008
Highest on
10/05/199
1001 Peel
3008
Lowest on
10/05/199
1003 Axelrod
3009
Highest on
10/04/199
1002 Serres
3010
Lowest on
10/06/199
1001 Peel
3011
Highest on
10/06/199
Dostları ilə paylaş: