8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2597d2b commit f51c125Copy full SHA for f51c125
README.md
@@ -592,4 +592,18 @@ GROUP BY title
592
ORDER BY AVG(rating) DESC, title ASC
593
LIMIT 1
594
)
595
+```
596
+
597
+[1321. Restaurant Growth](https://leetcode.com/problems/restaurant-growth/)
598
+```sql
599
+-- pay: last 7 days (today inclusive) - avg.amt (round, 2)
600
601
+SELECT visited_on, amount, ROUND(amount/7, 2) AS average_amount
602
+FROM (
603
+ SELECT DISTINCT visited_on,
604
+ SUM(amount) OVER(ORDER BY visited_on RANGE BETWEEN INTERVAL 6 DAY PRECEDING AND CURRENT ROW) AS amount,
605
+ MIN(visited_on) OVER() day_1
606
+ FROM Customer
607
+) t
608
+WHERE visited_on >= day_1+6;
609
```
0 commit comments