RienSQL
TASK #208 · Hard

The falling sales report picked up extra rows

Your brief
The report looks for employees whose sales are falling: their latest deal is smaller than their very first one.

Each such employee should appear once, but some repeat several times with different last deal amounts. The report also includes employees whose last deal is larger than the first.

Output name (employee name), first_amount (amount of the first deal) and last_amount (amount of the last deal).
Expected columnsname first_amount last_amountCompany
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
departmentsid, name
employeesid, name, department_id, manager_id, salary, hired_at
customersid, name, registered_at
ordersid, customer_id, employee_id, amount, created_at
loginsuser_id, logged_at