1-laboratoriya topshirig’i



Download 246,77 Kb.
bet4/5
Sana25.11.2022
Hajmi246,77 Kb.
#872441
1   2   3   4   5
Bog'liq
MMMM

1-yechim:
SELECT c.CustomerId, c.FirstName, c.LastName, sum(i.Total) as TotalSpent
FROM Customer c, Invoice i
WHERE c.CustomerId=i.CustomerId
GROUP BY (i.CustomerId)
ORDER BY TotalSpent desc
LIMIT 1;
2-yechim:
SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName, SUM(Invoice.Total) AS Invoices
FROM Customer
INNER JOIN Invoice ON Customer.CustomerID=Invoice.CustomerID
GROUP BY Customer.CustomerID
ORDER BY SUM(Invoice.Total) DESC LIMIT 1
4-savol. Chinook guruhi Rok musiqasini tinglaydigan barcha mijozlarni aniqlamoqchi. Barcha Rok musiqa tinglovchilarining elektron pochta manzilini, ismini, familiysini va janrini qaytarish uchun so‘rov yozing. Elektron pochta manzili bo‘yicha ’A’ bilan boshlanadigan alifbo tartibida ro‘yxat qaytaring.
Izoh: Mijozlarning pochtasi, ismi, familiyasini qaytarish uchun SELECT dan so’ng yoziladigan maydonlar nomlarini bilib olamiz. Undan so’ng esa so’ralgan topshiriqqa asosan qaysi jadvaldan ekanligini ko’rsatamiz, bu yerda Customer jadvalidan bo’ladi. So’ngra WHERE buyrug’idan keyin shartni yozishda so’rovga mos tarzda Rock janrini tinglovchilarni tanlaymiz va elektron pochtasini ORDER BY buyrug’i orqali tartiblaymiz. Ushbu savolga javob SQL so’rovi quyidagicha bo’ladi:
1-yechim:
SELECT distinct email,firstname,lastname,e.name
FROM Customer a,Invoice b,InvoiceLine c,Track d,Genre e
WHERE a.Customerid=b.Customerid AND b.Invoiceid=c.Invoiceid
AND c.Trackid=d.Trackid AND d.Genreid=e.Genreid AND e.name = 'Rock' ORDER BY email;
2-yechim:
SELECT Customer.Email, Customer.FirstName, Customer.LastName, Genre.Name
FROM Customer
INNER JOIN Invoice ON Customer.CustomerId=Invoice.CustomerId
INNER JOIN InvoiceLine ON Invoice.InvoiceId=InvoiceLine.InvoiceId
INNER JOIN Track ON InvoiceLine.TrackId=Track.TrackId
INNER JOIN Genre ON Genre.GenreId=Track.GenreId
WHERE Genre.Name="Rock"
GROUP BY Customer.CustomerId
ORDER BY Customer.Email



Download 246,77 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




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