135. Oy kesimida daromad
O'rtachaAgregatsiyalarUzum
Buyurtmalar aniq vaqt bilan (TIMESTAMP) saqlanadi. Ularni **kalendar
oylari** bo'yicha guruhlang.
DATE_TRUNC('month', ordered_at) vaqtni oyning birinchi kuniga
qisqartiradi — shu qiymat bo'yicha guruhlash mumkin.
month ustuni sana (DATE) turida chiqsin, ya'ni 2025-03-01
ko'rinishida.
Bir necha yilga tegishli ma'lumot bor — EXTRACT(MONTH ...) bilan yozsangiz
turli yillarning bir xil oylari qo'shilib ketadi.
Ustunlar: month, revenue, orders_count.
Saralash: month o'sish.
orders: id INT PK, ordered_at TIMESTAMP, amount NUMERIC(12,2)
Namuna ma'lumotlar
sample
orders
| idINT | ordered_atTIMESTAMP | amountNUMERIC(12,2) |
|---|---|---|
| 1 | 2024-11-03 09:15:00 | 120000 |
| 2 | 2024-11-27 18:40:00 | 85000 |
| 5 | 2025-01-02 08:20:00 | 210000 |
Kutilgan natija
| month | revenue | orders_count |
|---|---|---|
| 2024-11-01 | 205000 | 2 |
| 2025-01-01 | 210000 | 1 |
sample-full
orders
| idINT | ordered_atTIMESTAMP | amountNUMERIC(12,2) |
|---|---|---|
| 1 | 2024-11-03 09:15:00 | 120000 |
| 2 | 2024-11-27 18:40:00 | 85000 |
| 3 | 2024-12-05 12:00:00 | 300000 |
| 4 | 2024-12-31 23:59:00 | 45000 |
| 5 | 2025-01-02 08:20:00 | 210000 |
| 6 | 2025-01-19 14:05:00 | 95000 |
| 7 | 2025-01-30 21:10:00 | 60000 |
| 8 | 2025-02-14 10:00:00 | 180000 |
| 9 | 2025-02-28 16:45:00 | 220000 |
| 10 | 2025-03-01 00:01:00 | 35000 |
| 11 | 2025-03-15 11:30:00 | 90000 |
| 12 | 2025-03-31 19:20:00 | 55000 |
| 13 | 2025-11-08 13:00:00 | 40000 |
| 14 | 2025-11-22 17:35:00 | 75000 |
Kutilgan natija
| month | revenue | orders_count |
|---|---|---|
| 2024-11-01 | 205000 | 2 |
| 2024-12-01 | 345000 | 2 |
| 2025-01-01 | 365000 | 3 |
| 2025-02-01 | 400000 | 2 |
| 2025-03-01 | 180000 | 3 |
| 2025-11-01 | 115000 | 2 |
sample-extra
orders
| idINT | ordered_atTIMESTAMP | amountNUMERIC(12,2) |
|---|---|---|
| 1 | 2025-10-27 14:29:00 | 93336.91 |
| 2 | 2025-01-02 08:20:00 | 85000 |
| 3 | 2025-11-24 19:53:00 | 49000 |
| 4 | 2025-06-23 08:54:00 | 230154.18 |
| 5 | 2025-01-02 08:20:00 | 85000 |
Kutilgan natija
| month | revenue | orders_count |
|---|---|---|
| 2025-01-01 | 170000 | 2 |
| 2025-06-01 | 230154.18 | 1 |
| 2025-10-01 | 93336.91 | 1 |
| 2025-11-01 | 49000 | 1 |
O'xshash masalalar
Konsol
Natijani ko'rish uchun so'rovni ishga tushiring.
