Support ongoing development - donate to help us maintain and improve the platform. 🖥️ Support sqltest →
SQL code copied to buffer
Task 67:

Analyze customer payments

MySQL
For each customer, in the payment table, find the dates of his first and last payment, as well as the amount of all payments.
The query should return four columns: customer_id, first_payment_date – date of the first payment (in the format “YYYY-MM-DD”), last_payment_date – date of the last payment (in the format “YYYY-MM-DD”) and total_paid – total amount of client payments sorted in descending order of amount payments (in case of equal payment amounts - by ascending customer_id).
Expected result Columns: 4 · Rows: 599
customer_id first_payment_date last_payment_date total_paid

Sample rows open after wrong checks: 0 of 2

Write your query below and click "Check it!". Tables are described in the right pane.

The query result will appear here. Ctrl+Enter - Run query

Hi! Could we please enable some services and cookies to improve your experience and our website?

Privacy & Cookie Policy.