Sql server® 2012 t-sql fundamentals


   Microsoft SQL Server 2012 T-SQL Fundamentals 5



Download 10,93 Mb.
Pdf ko'rish
bet294/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   290   291   292   293   294   295   296   297   ...   443
Bog'liq
BookSQL

246  

Microsoft SQL Server 2012 T-SQL Fundamentals



5

If you understand the concept of grouping sets, this exercise should be straightforward for you. You 

can use the GROUPING SETS subclause to list the requested grouping sets and the GROUPING_ID 

function to produce a unique identifier for the grouping set with which each row is associated. Here’s 

the complete solution query.

SELECT 


  GROUPING_ID(empid, custid, YEAR(Orderdate)) AS groupingset, 

  empid, custid, YEAR(Orderdate) AS orderyear, SUM(qty) AS sumqty 

FROM dbo.Orders 

GROUP BY 

  GROUPING SETS 

  ( 


    (empid, custid, YEAR(orderdate)), 

    (empid, YEAR(orderdate)), 

    (custid, YEAR(orderdate)) 

  );


The requested grouping sets are neither a power set nor a rollup of some set of attributes. There-

fore, you cannot use either the CUBE or the ROLLUP subclause to further abbreviate the code. 

www.it-ebooks.info




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   290   291   292   293   294   295   296   297   ...   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