diff --git a/solution/1300-1399/1321.Restaurant Growth/README.md b/solution/1300-1399/1321.Restaurant Growth/README.md index 1fe8b4e3532d4..174d70118f3b1 100644 --- a/solution/1300-1399/1321.Restaurant Growth/README.md +++ b/solution/1300-1399/1321.Restaurant Growth/README.md @@ -104,4 +104,18 @@ FROM t WHERE rk > 6; ``` +```sql +# Write your MySQL query statement below +SELECT + a.visited_on, + SUM(b.amount) AS amount, + ROUND(SUM(b.amount) / 7, 2) AS average_amount +FROM + (SELECT DISTINCT visited_on FROM customer) AS a + JOIN customer AS b ON DATEDIFF(a.visited_on, b.visited_on) BETWEEN 0 AND 6 +WHERE a.visited_on >= (SELECT MIN(visited_on) FROM customer) + 6 +GROUP BY 1 +ORDER BY 1; +``` + diff --git a/solution/1300-1399/1321.Restaurant Growth/README_EN.md b/solution/1300-1399/1321.Restaurant Growth/README_EN.md index 5f60697e754ce..ab91dc98bd5f9 100644 --- a/solution/1300-1399/1321.Restaurant Growth/README_EN.md +++ b/solution/1300-1399/1321.Restaurant Growth/README_EN.md @@ -100,4 +100,18 @@ FROM t WHERE rk > 6; ``` +```sql +# Write your MySQL query statement below +SELECT + a.visited_on, + SUM(b.amount) AS amount, + ROUND(SUM(b.amount) / 7, 2) AS average_amount +FROM + (SELECT DISTINCT visited_on FROM customer) AS a + JOIN customer AS b ON DATEDIFF(a.visited_on, b.visited_on) BETWEEN 0 AND 6 +WHERE a.visited_on >= (SELECT MIN(visited_on) FROM customer) + 6 +GROUP BY 1 +ORDER BY 1; +``` +