Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet277/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   273   274   275   276   277   278   279   280   ...   443
Bog'liq
BookSQL

 

CHAPTER 7

 

Beyond the Fundamentals of Querying



 

 229

The table has a row for each employee; a column for each of the four customers A, B, C, and D; 

and the order quantity for each employee and customer in the employee-customer intersections. 

Notice that irrelevant intersections (employee-customer combinations that had no intersecting order 

activity) are represented by NULL marks. Suppose that you receive a request to unpivot the data

requiring you to return a row for each employee and customer, along with the order quantity. The 

resulting output should look like this.

empid       custid    qty 

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

1           B         20 

1           C         34 

2           A         52 

2           B         27 

3           A         20 

3           C         22 

3           D         30

In the following sections, I’ll discuss two techniques for solving this problem—a technique that fol-

lows the SQL standard and a technique that uses a T-SQL–specific UNPIVOT operator.




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   273   274   275   276   277   278   279   280   ...   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