Bahriddinov shodbek


Download 1.04 Mb.
bet2/3
Sana11.11.2021
Hajmi1.04 Mb.
1   2   3
Lab1

Q 1

SELECT invoice.*

FROM invoice

where invoice.invoicedate between '2013-01-01' and '2014-01-01';



Q2

SELECT firstName,lastName,country

FROM customer

WHERE country IN("Brazil","Canada","India","Sweden");



Q3

SELECT Track.name, Track.Composer, Album.Title

FROM Track

JOIN Album

ON Track.AlbumId = Album.AlbumId

WHERE Track.name LIKE 'A%' AND Track.Composer NOT LIKE '';



Q4

SELECT C.Firstname,C.Lastname,I.Total

FROM Customer AS C

JOIN Invoice AS I

ON C.CustomerId =I.CustomerId

ORDER BY I.total DESC

LIMIT 10

Lab 2

Q1

SELECT BillingCountry, count(*) as Invoices

FROM Invoice

GROUP BY BillingCountry

ORDER BY Invoices desc;

Q2

SELECT customer.city,sum(invoice.Total)

from customer,invoice

where customer.CustomerId=Invoice.CustomerId

group by customer.city

order by sum(invoice.Total) desc

limit 1;

Q3

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;

Q4

SELECT DISTINCT

C.Email AS email,

C.FirstName AS firstName,

C.LastName AS lastName,

G.Name AS name

FROM Customer C JOIN Invoice I

ON C.CustomerId = I.CustomerId JOIN InvoiceLine IL

ON I.InvoiceId = IL.InvoiceId JOIN Track T

ON IL.TrackId = T.TrackId JOIN Genre G

ON T.GenreId = G.GenreId

WHERE G.Name = "Rock"

ORDER BY C.Email;

Q5

WITH tab1 AS

(

SELECT c.CustomerId, c.FirstName, c.LastName, c.Country, SUM(i.Total) TotalSpent



FROM Customer c

JOIN Invoice i ON c.CustomerId = i.CustomerId

GROUP BY c.CustomerId

)

SELECT tab1.*



FROM tab1

JOIN


(

SELECT CustomerId, FirstName, LastName, Country, MAX(TotalSpent) AS TotalSpent

FROM tab1

GROUP BY Country

) tab2

ON tab1.Country = tab2.Country



WHERE tab1.TotalSpent = tab2.TotalSpent

ORDER BY Country;





5- labaratoriya ishi

Ishdan maqsad: Ushbu laboratoriya ishining maqsadi talabalar qanday saralash usullari va algoritmlari mavjudligini va ularning samaradorliklarini baholashni o‘rganishlari kerak. Shu asosda saralash usullarini qiyosiy tahlil qilishlari, C++ dasturlash tilida fayllar bilan ishlashni va ularga oid dasturlar tuzishni o‘zlashtirishlari kerak.


Download 1.04 Mb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2020
ma'muriyatiga murojaat qiling