Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet85/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   81   82   83   84   85   86   87   88   ...   443
Bog'liq
BookSQL

The 

ORDER BY

 Clause

The ORDER BY clause allows you to sort the rows in the output for presentation purposes. In terms of 

logical query processing, ORDER BY is the very last clause to be processed. The sample query shown 

in Listing 2-4 sorts the rows in the output by employee ID and order year.



LISTING 2-4

  Query Demonstrating the ORDER BY Clause

SELECT empid, YEAR(orderdate) AS orderyear, COUNT(*) AS numorders 

FROM Sales.Orders 

WHERE custid = 71 

GROUP BY empid, YEAR(orderdate) 

HAVING COUNT(*) > 1 

ORDER BY empid, orderyear;

This query generates the following output.

empid       orderyear   numorders 

----------- ----------- ----------- 

1           2007        2 

1           2008        3 

2           2008        2 

3           2007        2 

4           2008        3 

5           2007        3 

6           2007        3 

7           2008        2 

8           2007        4 

 

(9 row(s) affected)



www.it-ebooks.info



Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   81   82   83   84   85   86   87   88   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish