13. Payme: oylik o'sish
O'rtachaWindow funksiyalarPayme
Payme oylik aylanmasi monthly_revenue jadvalida.
Har bir oy uchun oldingi oyga nisbatan o'zgarishni hisoblang:
month, revenue, prev_revenue, diff.
prev_revenue— oldingi oy aylanmasi (birinchi oy uchunNULL)diff—revenue - prev_revenue(birinchi oy uchunNULL)
Natijani oy bo'yicha o'sish tartibida saralang.
Jadval: monthly_revenue
| Ustun | Turi |
|---|---|
| month | DATE |
| revenue | NUMERIC(14,2) |
Namuna ma'lumotlar
sample
monthly_revenue
| monthDATE | revenueNUMERIC(14,2) |
|---|---|
| 2025-01-01 | 120000000 |
| 2025-02-01 | 135000000 |
| 2025-03-01 | 128000000 |
Kutilgan natija
| diff | month | revenue | prev_revenue |
|---|---|---|---|
| NULL | 2025-01-01 | 120000000 | NULL |
| 15000000 | 2025-02-01 | 135000000 | 120000000 |
| -7000000 | 2025-03-01 | 128000000 | 135000000 |
sample-full
monthly_revenue
| monthDATE | revenueNUMERIC(14,2) |
|---|---|
| 2024-07-01 | 98000000 |
| 2024-08-01 | 104500000 |
| 2024-09-01 | 99800000 |
| 2024-10-01 | 117200000 |
| 2024-11-01 | 125900000 |
| 2024-12-01 | 168400000 |
| 2025-01-01 | 120000000 |
| 2025-02-01 | 135000000 |
| 2025-03-01 | 128000000 |
| 2025-04-01 | 141700000 |
| 2025-05-01 | 153200000 |
| 2025-06-01 | 149900000 |
Kutilgan natija
| diff | month | revenue | prev_revenue |
|---|---|---|---|
| NULL | 2024-07-01 | 98000000 | NULL |
| 6500000 | 2024-08-01 | 104500000 | 98000000 |
| -4700000 | 2024-09-01 | 99800000 | 104500000 |
| 17400000 | 2024-10-01 | 117200000 | 99800000 |
| 8700000 | 2024-11-01 | 125900000 | 117200000 |
| 42500000 | 2024-12-01 | 168400000 | 125900000 |
| -48400000 | 2025-01-01 | 120000000 | 168400000 |
| 15000000 | 2025-02-01 | 135000000 | 120000000 |
| -7000000 | 2025-03-01 | 128000000 | 135000000 |
| 13700000 | 2025-04-01 | 141700000 | 128000000 |
| 11500000 | 2025-05-01 | 153200000 | 141700000 |
| -3300000 | 2025-06-01 | 149900000 | 153200000 |
sample-extra
monthly_revenue
| monthDATE | revenueNUMERIC(14,2) |
|---|---|
| 2024-11-01 | 170149351.71 |
| 2024-12-16 | 125900000 |
| 2025-04-28 | 107478100 |
| 2025-02-18 | 97374500 |
Kutilgan natija
| diff | month | revenue | prev_revenue |
|---|---|---|---|
| NULL | 2024-11-01 | 170149351.71 | NULL |
| -44249351.71 | 2024-12-16 | 125900000 | 170149351.71 |
| -28525500 | 2025-02-18 | 97374500 | 125900000 |
| 10103600 | 2025-04-28 | 107478100 | 97374500 |
O'xshash masalalar
Konsol
Natijani ko'rish uchun so'rovni ishga tushiring.
