Having standart so‘zi orqali so‘rovlar yaratish


Download 25.28 Kb.
Sana25.01.2023
Hajmi25.28 Kb.
#1119128
Bog'liq
etgfe


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 25.28 Kb.

Do'stlaringiz bilan baham:




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