Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet80/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   76   77   78   79   80   81   82   83   ...   443
Bog'liq
BookSQL

HAVING COUNT(*) > 1

Recall that the GROUP BY phase created 16 groups of employee ID and order year. Seven of those 

groups have only one row, so after the HAVING clause is processed, nine groups remain. Run the fol-

lowing query to return those nine groups.

SELECT empid, YEAR(orderdate) AS orderyear 

FROM Sales.Orders 

WHERE custid = 71 

GROUP BY empid, YEAR(orderdate) 

HAVING COUNT(*) > 1;

This query returns the following output.

empid       orderyear 

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

1           2007 

3           2007 

5           2007 

6           2007 

8           2007 

1           2008 

2           2008 

4           2008 

7           2008 

 

(9 row(s) affected)



The 

SELECT

 Clause

The SELECT clause is where you specify the attributes (columns) that you want to return in the result 

table of the query. You can base the expressions in the SELECT list on attributes from the queried 

tables, with or without further manipulation. For example, the SELECT list in Listing 2-1 has the follow-

ing expressions: empidYEAR(orderdate), and COUNT(*). If an expression refers to an attribute with no 

manipulation, such as empid, the name of the target attribute is the same as the name of the source 

www.it-ebooks.info




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   76   77   78   79   80   81   82   83   ...   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