🙏 Thank you for your support last month! Thanks to you, the project keeps growing. We'd be grateful if you could support us again this month. Support again →
SQL code copied to buffer
Task 95:

Analyze customer payments

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

Use MySQL syntax to write your answer. Descriptions of tables are provided in the right pane.

Write your request in the field below and click the "Check it!" button.
Get hint
Copy code Clear editor

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

Privacy & Cookie Policy.