❤️ Thank you to everyone who supported the project! Last month you donated almost $100 — this keeps the service running free for everyone this month. I hope to count on your support for next month too. Support now →
SQL code copied to buffer
RU PT FR
Task 4:

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.