Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet87/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   83   84   85   86   87   88   89   90   ...   443
Bog'liq
BookSQL

The 

TOP

 and 

OFFSET-FETCH

 Filters

Earlier in this chapter, I covered filters that are based on the predicates WHERE and HAVING. In this 

section, I cover filters that are based on number of rows and ordering. I’ll start with a filter called TOP 

that has been supported in SQL Server for quite some time—since version 7.0. Then I’ll introduce a 

new filter called OFFSET-FETCH that was introduced in SQL Server 2012.

The 

TOP

 Filter

The TOP option is a proprietary T-SQL feature that allows you to limit the number or percentage of 

rows that your query returns. It relies on two elements as part of its specification; one is the number 

or percent of rows to return, and the other is the ordering. For example, to return from the Orders 

table the five most recent orders, you would specify TOP (5) in the SELECT clause and orderdate DESC 

in the ORDER BY clause, as shown in Listing 2-5.



LISTING 2-5

  Query Demonstrating the TOP Option

SELECT TOP (5) orderid, orderdate, custid, empid 

FROM Sales.Orders 

ORDER BY orderdate DESC;

www.it-ebooks.info





Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   83   84   85   86   87   88   89   90   ...   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