Sql server® 2012 t-sql fundamentals


   Microsoft SQL Server 2012 T-SQL Fundamentals Exercises



Download 10,93 Mb.
Pdf ko'rish
bet233/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   229   230   231   232   233   234   235   236   ...   443
Bog'liq
BookSQL

182  

Microsoft SQL Server 2012 T-SQL Fundamentals



Exercises 

This section provides exercises to help you familiarize yourself with the subjects discussed in this chap-

ter. All the exercises in this chapter require your session to be connected to the TSQL2012 database.

1-1

Write a query that returns the maximum value in the orderdate column for each employee.



Tables involved: TSQL2012 database, Sales.Orders table



Desired output:



empid       maxorderdate 

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

3           2008-04-30 00:00:00.000 

6           2008-04-23 00:00:00.000 

9           2008-04-29 00:00:00.000 

7           2008-05-06 00:00:00.000 

1           2008-05-06 00:00:00.000 

4           2008-05-06 00:00:00.000 

2           2008-05-05 00:00:00.000 

5           2008-04-22 00:00:00.000 

8           2008-05-06 00:00:00.000 

 

(9 row(s) affected)



1-2

Encapsulate the query from Exercise 1-1 in a derived table. Write a join query between the derived 

table and the Orders table to return the orders with the maximum order date for each employee.



Tables involved: Sales.Orders



Desired output:

empid       orderdate                 orderid     custid 

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

9           2008-04-29 00:00:00.000   11058       6 

8           2008-05-06 00:00:00.000   11075       68 

7           2008-05-06 00:00:00.000   11074       73 

6           2008-04-23 00:00:00.000   11045       10 

5           2008-04-22 00:00:00.000   11043       74 

4           2008-05-06 00:00:00.000   11076       9 

3           2008-04-30 00:00:00.000   11063       37 

2           2008-05-05 00:00:00.000   11073       58 

2           2008-05-05 00:00:00.000   11070       44 

1           2008-05-06 00:00:00.000   11077       65 

 

(10 row(s) affected)



www.it-ebooks.info



Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   229   230   231   232   233   234   235   236   ...   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