1- yechim:
SELECT billingcountry, count(invoicedate) AS Invoices
FROM Invoice GROUP BY billingcountry
ORDER BY Invoices DESC;
2- yechim:
SELECT Invoice.BillingCountry, COUNT(Invoice.BillingCountry)
FROM Invoice
GROUP BY Invoice.BillingCountry
ORDER BY COUNT(Invoice.Total) DESC;
2-savol. Biz eng ko‘p pul ishlagan shaharda reklama musiqiy festivalini o‘tkazmoqchimiz. Hisob-fakturalar summasi eng ko‘p bo‘lgan shaharni qaytaradigan so‘rov yozing. Shahar nomini va barcha hisob-fakturalar summasini qaytaring.
Ikkinchi savolga mos so’rov yozish uchun uni tahlil qilaylik va qaysi jadvaldan foydalanish kerakligini o’ylab ko’raylik. Shaharni tanlash uchun SELECTdan so’ng billingcityni yozamiz. Eng ko’p pul ishlaganlarni topish uchun MAX() ni ishlatamiz. Shahar nomini va barcha invoicelarni qaytarish uchun ikkinchi SELECTdan foydalanamiz. Natija quyidagicha bo’ladi.
Do'stlaringiz bilan baham: |