Select country, count(*) from customers group by country; select age, count(*) from customers group by age limit 2


Download 111.09 Kb.
Sana17.06.2023
Hajmi111.09 Kb.
#1530456
Bog'liq
6-amaliy


SELECT country, count(*) FROM Customers group by country;
SELECT age, count(*) FROM Customers group by age limit 2;
SELECT status, count(*) FROM Shippings group by status;
SELECT customer_id, count(*) from Orders group by customer_id;
SELECT * FROM Customers group by country;

SELECT
e.customer_id,


e.first_name,
e.last_name,
sum(o.amount)
FROM
customers e
INNER JOIN
orders o ON e.customer_id = o.customer_id
GROUP BY e.customer_id;

Filmlar


Tomoshabin

Reyting

Reyting jadvalida filmlar nechtadan ovozga ekanligini aniqlash.
select film_id, count(*) from reyting group by film_id order by count(*);
Reyting jadvalida filmlar to’plagan ballar va uni kamayish taribida aniqlash.
select film_id, sum(ball) from reyting group by film_id order by sum(ball) desc ;
Reyting va Filmlar jadvallarini bog’lagan holda filmlar to’plagan ballar va uni kamayish taribida aniqlash. 60 balldan yuqorilarini chiqarish.
select film_nomi, sum(ball) from reyting inner join filmlar on reyting.film_id=filmlar.id group by film_id having sum(ball)>60 order by sum(ball) desc ;
Download 111.09 Kb.

Do'stlaringiz bilan baham:




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