12. Uzum: kategoriya bo'yicha daromad
O'rtachaUzum buyurtmalari order_items, mahsulotlar products jadvalida.
Har bir kategoriya uchun umumiy daromadni hisoblang:
daromad = quantity * unit_price yig'indisi.
Faqat umumiy daromadi 10 000 000 dan katta kategoriyalarni qaytaring:
category, revenue.
Natijani daromad bo'yicha kamayish tartibida saralang.
Jadvallar
products:
| Ustun | Turi |
|---|---|
| id | INT PK |
| name | VARCHAR |
| category | VARCHAR |
order_items:
| Ustun | Turi |
|---|---|
| id | INT PK |
| product_id | INT |
| quantity | INT |
| unit_price | NUMERIC(12,2) |
Namuna ma'lumotlar
sample-basic
products
| idINT | nameVARCHAR(100) | categoryVARCHAR(50) |
|---|---|---|
| 1 | P1 | Elektronika |
| 2 | P2 | Elektronika |
| 3 | P3 | Maishiy |
| 4 | P4 | Maishiy |
| 5 | P5 | Kiyim |
order_items
| idINT | product_idINT | quantityINT | unit_priceNUMERIC(12,2) |
|---|---|---|---|
| 1 | 1 | 3 | 4500000 |
| 2 | 2 | 2 | 9800000 |
| 3 | 3 | 1 | 8200000 |
| 4 | 4 | 2 | 7400000 |
| 5 | 5 | 5 | 300000 |
Kutilgan natija
| revenue | category |
|---|---|
| 33100000 | Elektronika |
| 23000000 | Maishiy |
sample-one-cat
products
| idINT | nameVARCHAR(100) | categoryVARCHAR(50) |
|---|---|---|
| 1 | P1 | Elektronika |
order_items
| idINT | product_idINT | quantityINT | unit_priceNUMERIC(12,2) |
|---|---|---|---|
| 1 | 1 | 5 | 9800000 |
Kutilgan natija
| revenue | category |
|---|---|
| 49000000 | Elektronika |
sample-all-below
products
| idINT | nameVARCHAR(100) | categoryVARCHAR(50) |
|---|---|---|
| 1 | P1 | Kitob |
| 2 | P2 | Kiyim |
order_items
| idINT | product_idINT | quantityINT | unit_priceNUMERIC(12,2) |
|---|---|---|---|
| 1 | 1 | 2 | 89000 |
| 2 | 2 | 1 | 300000 |
O'xshash masalalar
Konsol
Natijani ko'rish uchun so'rovni ishga tushiring.
