Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet270/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   266   267   268   269   270   271   272   273   ...   443
Bog'liq
BookSQL

Pivoting Data

Pivoting data involves rotating data from a state of rows to a state of columns, possibly aggregating 

values along the way. Don’t worry that this description isn’t enough to clarify exactly what pivoting 

data means; this is a subject best explained through examples. In many cases, pivoting of data is 

handled by the presentation layer. This section teaches you how to handle pivoting with T-SQL for 

those cases that you do decide to handle in the database.

For the rest of the topics in this chapter, I use a sample table called dbo.Orders that you create and 

populate in the TSQL2012 database by running the code in Listing 7-1. 



LISTING 7-1

  Code to Create and Populate the dbo.Orders Table

USE TSQL2012; 

 

IF OBJECT_ID('dbo.Orders', 'U') IS NOT NULL DROP TABLE dbo.Orders; 



 

CREATE TABLE dbo.Orders 

 

 



  orderid   INT        NOT NULL, 

  orderdate DATE       NOT NULL, 

  empid     INT        NOT NULL, 

  custid    VARCHAR(5) NOT NULL, 

  qty       INT        NOT NULL, 

  CONSTRAINT PK_Orders PRIMARY KEY(orderid) 

);

www.it-ebooks.info





Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   266   267   268   269   270   271   272   273   ...   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