Har bir oy uchun do‘kon tushumini (quantity * price yig‘indisi) va yil boshidan shu oygacha jamlangan tushumni chiqaring. Faqat buyurtma bo‘lgan oylar, oy bo‘yicha o‘sish tartibida.
Maslahat: oyni strftime('%Y-%m', order_date) bilan oling; jamlangan yig‘indi — SUM(...) OVER (ORDER BY ...).
Namunaviy ma‘lumotlar
| id integer | name text | category text | price integer | stock integer |
|---|---|---|---|---|
| 1 | Planshet | Elektronika | 335000 | 61 |
| 2 | Kamera | Elektronika | 110000 | 45 |
| 3 | Guruch | Oziq-ovqat | 2335000 | 19 |
| 4 | Shapka | Kiyim | 2710000 | 61 |
| 5 | Aqlli soat | Elektronika | 1595000 | 66 |
| 6 | Asal | Oziq-ovqat | 2700000 | 23 |
| 7 | Futbolka | Kiyim | 1780000 | 108 |
| 8 | Quloqchin | Elektronika | 2150000 | 19 |
| 9 | Mehrobdan chayon | Kitoblar | 2950000 | 14 |
| id integer | customer_id integer | order_date text |
|---|---|---|
| 1 | 1 | 2025-03-24 |
| 2 | 1 | 2025-03-25 |
| 3 | 1 | 2025-03-26 |
| 4 | 2 | 2025-06-09 |
| 5 | 2 | 2025-06-10 |
| 6 | 5 | 2025-02-07 |
| 7 | 1 | 2025-06-10 |
| 8 | 3 | 2025-01-08 |
| 9 | 2 | 2025-06-28 |
| 10 | 2 | 2025-01-26 |
| 11 | 3 | 2025-08-10 |
| 12 | 5 | 2025-03-23 |
| 13 | 2 | 2025-02-16 |
| 14 | 5 | 2025-03-04 |
| order_id integer | product_id integer | quantity integer |
|---|---|---|
| 1 | 5 | 2 |
| 1 | 6 | 5 |
| 2 | 9 | 3 |
| 2 | 4 | 5 |
| 3 | 8 | 4 |
| 3 | 2 | 2 |
| 3 | 1 | 1 |
| 4 | 9 | 2 |
| 5 | 1 | 3 |
| 5 | 6 | 2 |
| 6 | 6 | 5 |
| 7 | 3 | 3 |
| 7 | 1 | 1 |
| 7 | 8 | 5 |
| 8 | 4 | 5 |
| 8 | 6 | 2 |
| 8 | 8 | 1 |
| 9 | 8 | 2 |
| 9 | 6 | 3 |
| 10 | 7 | 1 |
| 11 | 3 | 1 |
| 11 | 4 | 5 |
| 12 | 4 | 2 |
| 12 | 1 | 2 |
| 13 | 3 | 1 |
| 13 | 5 | 1 |
| 13 | 1 | 3 |
| 14 | 6 | 2 |
| 14 | 4 | 1 |
| 14 | 7 | 5 |
Jadval tuzilishi (CREATE TABLE)
CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, category TEXT, price INTEGER, stock INTEGER); CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER, order_date TEXT); CREATE TABLE order_items (order_id INTEGER, product_id INTEGER, quantity INTEGER);
Natija
Uch ustun: month (masalan 2025-03), revenue, running_total. Tartib muhim.
Namunaviy ma‘lumotlarda kutilgan natija
| 2025-01 | 22880000 | 22880000 |
| 2025-02 | 18435000 | 41315000 |
| 2025-03 | 71345000 | 112660000 |
| 2025-06 | 42795000 | 155455000 |
| 2025-08 | 15885000 | 171340000 |
Qatorlar aynan shu tartibda bo‘lishi kerak. Yechim yashirin, kattaroq ma‘lumotlarda ham tekshiriladi.