Having standart so‘zi orqali so‘rovlar yaratish


Download 24.47 Kb.
Sana14.11.2021
Hajmi24.47 Kb.
#174597

HAVING standart so‘zi orqali so‘rovlar yaratish.

HAVING operatori GROUP BY operatori bilan birgalikda guruhlar uchun asosan agregat funksiya natijalariga shart berish orqali cheklovlar o’rnatish uchun ishlatiladi. HAVING operatori sintaksisi quyidagicha:

SELECT

select_list

FROM

table_name



WHERE

search_condition

GROUP BY

group_by_expression

HAVING

group_condition;



Bu sintaksisda GROUP BY orqali hosil qilngan satrlar, group_condition o’rnida berilgan shart rost qiymat qabul qilganda natijaviy jadvalga kiritiladi. HAVING operatori bajarilish tartibi:

SELECT product, SUM(quantity) AS "Total quantity"

FROM order_details

GROUP BY product

HAVING SUM(quantity) > 10;

SELECT

ordernumber,

SUM(quantityOrdered) AS itemsCount,

SUM(priceeach*quantityOrdered) AS total

FROM


orderdetails

GROUP BY

ordernumber

HAVING


total > 1000;

SELECT


ordernumber,

SUM(quantityOrdered) AS itemsCount,

SUM(priceeach*quantityOrdered) AS total

FROM


orderdetails

GROUP BY ordernumber

HAVING

total > 1000 AND



itemsCount > 600;
Download 24.47 Kb.

Do'stlaringiz bilan baham:




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