Group by va order by standart so‘zlaridan foydalanib so’rov yaratish. Order by


Download 41.63 Kb.
Sana06.11.2021
Hajmi41.63 Kb.
#171296
Bog'liq
Bayonnomalari, Maqola Ali, Maqola Ali, Maqolalar2020, kichik biznes oraliq, 1 - mavzu, yoruglikning qutblanishi. yoruglikning ikki muhit chegarasidan qaytgandagi va singandagi qutblanishi. bryuster qonuni., turkiy filologiyaga kirish maruza matni, turkiy filologiyaga kirish maruza matni, 10-MAVZU-prez (2), Шеър поэтикаси-107-мажмуа, funksional va darajali qatorlar , 3-sinf Bo’lishli va bo’lishsiz fe’llar, §. Natural va butun sonlar, ILMIY MAQOLA SALOXIDDIN RAXMATOV TAXRIRI

GROUP BY va ORDER BY

standart so‘zlaridan foydalanib so’rov yaratish.

ORDER BY operatori qiymatlarni bir yoki bir nechta ustunlar bo'yicha saralaydi. ORDER BY operatori sintaksisi quyidagicha:

SELECT


select_list

FROM


table_name

ORDER BY

column1 [ASC|DESC],

column2 [ASC|DESC],

...;

ASC kalit so’zi ustunni o’sish tartibida saralashni, DESC esa kamayish tartibida saralashni bildiradi. Odatiy qiymat ASC.



Natijaviy to’plamni column1 ustuni bo’yicha o’sish tartibida saralash:

ORDER BY column1 ASC;

Yoki

ORDER BY column1;



Natijaviy to’plamni column1 ustuni bo’yicha o’sish tartibida saralash:

ORDER BY column1 DESC;



ORDER BY operatori SELECT va FROM operatorlaridan so’ng bajariladi:

Familiya ustuni bo’yicha saralash:

SELECT

contactLastname,



contactFirstname

FROM


customers

ORDER BY


contactLastname;

Familiya ustuni bo’yicha kamayish tartibida saralash:

SELECT

contactLastname,



contactFirstname

FROM


customers

ORDER BY


contactLastname DESC;

Saralashni ifoda orqali amalga oshirish:

SELECT

orderNumber,

orderlinenumber,

quantityOrdered * priceEach

FROM

orderdetails



ORDER BY

quantityOrdered * priceEach DESC;



GROUP BY operatori qatorlar to'plamini ustunlar yoki ifodalar qiymatlari bo'yicha natijaviy qatorlar to'plamiga guruhlaydi. GROUP BY operatori har bir guruh uchun bitta qatorni qaytaradi. Boshqacha qilib aytganda, natijalar to'plamidagi qatorlar sonini kamaytiradi.

GROUP BY operatori ko’pincha agregat funksiyalar bilan ishlatiladi. GROUP BY operatori sintaksisi quyidagicha:

SELECT

c1, c2,..., cn, aggregate_function(ci)

FROM

table


WHERE

where_conditions

GROUP BY c1 , c2,...,cn;

GROUP BY operatori bajarilish o’rni:



GROUP BY operatori bilan agregat funksiyalarning ishlatishiga misol:




Download 41.63 Kb.

Do'stlaringiz bilan baham:




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