Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet76/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   72   73   74   75   76   77   78   79   ...   443
Bog'liq
BookSQL

The 

GROUP BY

 Clause

The GROUP BY phase allows you to arrange the rows returned by the previous logical query proc-

essing phase in groups. The groups are determined by the elements you specify in the GROUP BY 

clause. For example, the GROUP BY clause in the query in Listing 2-1 has the elements empid and 



YEAR(orderdate)

FROM Sales.Orders 

WHERE custid = 71 

GROUP BY empid, YEAR(orderdate)

This means that the GROUP BY phase produces a group for each unique combination of employee 

ID and order year values that appears in the data returned by the WHERE phase. The expression 

YEAR(orderdate) invokes the YEAR function to return only the year part from the orderdate column.

The WHERE phase returned 31 rows, within which there are 16 unique combinations of employee 

ID and order year values, as shown here.

empid       YEAR(orderdate) 

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

1           2006 

1           2007 

1           2008 

2           2006 

2           2007 

2           2008 

3           2007 

4           2007 

4           2008 

5           2007 

6           2007 

6           2008 

7           2007 

7           2008 

8           2007 

9           2006

www.it-ebooks.info





Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   72   73   74   75   76   77   78   79   ...   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