New month, new goals. Your help keeps the project moving forward. 🖥️ Support sqltest →
SQL code copied to buffer
Task 4:

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).

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.