"content":"<p>Table: <code>Customer</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| customer_id | int |\n| name | varchar |\n| visited_on | date |\n| amount | int |\n+---------------+---------+\nIn SQL,(customer_id, visited_on) is the primary key for this table.\nThis table contains data about customer transactions in a restaurant.\nvisited_on is the date on which the customer with ID (customer_id) has visited the restaurant.\namount is the total paid by a customer.\n</pre>\n\n<p> </p>\n\n<p>You are the restaurant owner and you want to analyze a possible expansion (there will be at least one customer every day).</p>\n\n<p>Compute the moving average of how much the customer paid in a seven days window (i.e., current day + 6 days before). <code>average_amount</code> should be <strong>rounded to two decimal places</strong>.</p>\n\n<p>Return the result table ordered by <code>visited_on</code> <strong>in ascending order</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nCustomer table:\n+-------------+--------------+--------------+-------------+\n| customer_id | name | visited_on | amount |\n+-------------+--------------+--------------+-------------+\n| 1 | Jhon | 2019-01-01 | 100 |\n| 2 | Daniel | 2019-01-02 | 110 |\n| 3 | Jade | 2019-01-03 | 120 |\n| 4 | Khaled | 2019-01-04 | 130 |\n| 5 | Winston | 2019-01-05 | 110 | \n| 6 | Elvis | 2019-01-06 | 140 | \n| 7 | Anna | 2019-01-07 | 150 |\n| 8 | Maria | 2019-01-08 | 80 |\n| 9 | Jaze | 2019-01-09 | 110 | \n| 1 | Jhon | 2019-01-10 | 130 | \n| 3 | Jade | 2019-01-10 | 150 | \n+-------------+--------------+--------------+-------------+\n<strong>Output:</strong> \n+--------------+--------------+----------------+\n| visited_on | amount | average_amount |\n+--------------+--------------+----------------+\n| 2019-01-07 | 860 | 122.86 |\n| 2019-01-08 | 840 | 120 |\n| 2019-01-09 | 840 | 120 |\n| 2019-01-10 | 1000 | 142.86 |\n+--------------+--------------+----------------+\n<strong>Explanation:</strong> \n1st moving average from 2019-01-01 to 2019-01-07 has an average_amount of (100 + 110 + 120 + 130 + 110 + 140 + 150)/7 = 122.86\n2nd moving average from 2019-01-02 to 2019-01-08 has an average_amount of (110 + 120 + 130 + 110 + 140 + 150 + 80)/7 = 120\n3rd moving average from 2019-01-03 to 2019-01-09 has an average_amount of (120 + 130 + 110 + 140 + 150 + 80 + 110)/7 = 120\n4th moving average from 2019-01-04 to 2019-01-10 has an average_amount of (130 + 110 + 140 + 150 + 80 + 110 + 130 + 150)/7 = 142.86\n</pre>\n",