Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet284/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   280   281   282   283   284   285   286   287   ...   443
Bog'liq
BookSQL

The 

CUBE

 Subclause

The CUBE subclause of the GROUP BY clause provides an abbreviated way to define multiple group-

ing sets. In the parentheses of the CUBE subclause, you provide a list of members separated by 

commas, and you get all possible grouping sets that can be defined based on the input members. For 

example, CUBE(a, b, c) is equivalent to GROUPING SETS( (a, b, c), (a, b), (a, c), (b, c), (a), (b), (c), () ). In 

set theory, the set of all subsets of elements that can be produced from a particular set is called the 

power set. You can think of the CUBE subclause as producing the power set of grouping sets that can 

be formed from the given set of elements.

Instead of using the GROUPING SETS subclause in the previous query to define the four group-

ing sets (empid, custid)(empid)(custid), and (), you can simply use CUBE(empid, custid). Here’s the 

complete query.

SELECT empid, custid, SUM(qty) AS sumqty 

FROM dbo.Orders 

GROUP BY CUBE(empid, custid);

www.it-ebooks.info




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   280   281   282   283   284   285   286   287   ...   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