Ishni bajarish tartibi
“O’yinchilar soni” ni aniqlash maqsadida hosil qilingan ma’lumotlar bazamiz
ustida ish
olib boramiz.
1. O’yinchilar sonini aniqlashda qaysi mamlakatdan nechta o’yinchi borligini topamiz:
buning uchun barselona jadvalidagi
country ustunini
group by
yordamida
birlashtirib
yuboramiz.
Count(*) – sonini hissoblash uchun ishlatiladi
So‘rov:
select country, count(*) as oyinchi_soni from barselona group by country;
Natija:
6.1-rasm. Group by
kalit so‘zidan foydalanish
2. Topilgan natijani mamlakatlar nomi bo’yicha tartiblaymiz buning uchun so’rovimizga
order by country
buyurug’ini qo’shamiz.
So‘rov: select country, count(*) as oyinchi_soni from barselona group by country
order by country;
Natija:
6.2 –rasm. Group by
kalit va
Order by
kalit so‘zlaridan foydalanish
3.
O’yinchilar nomi alifbo bo‘yicha tartiblansin va alifboga teskari tartibda tartiblansin.
O’yinchilar nomini alifbo bo‘yicha tartiblash:
So‘rov: select player_id, player_name, birth_year, country from barselona order
by player_name;
Natija:
6.3–rasm. Order by
kalit so‘zining qo‘llanilishi
4. O’yinchilar nomini alifboga teskari tartib bo‘yicha tartiblash:
Dostları ilə paylaş: