The finance team wants to spot unusually large orders. Find every invoice whose Total is greater than the average Total across all invoices, using a scalar subquery.
Return InvoiceId, CustomerId, InvoiceDate, and Total, ordered by Total descending (ties broken by InvoiceId ascending).
| Column | Type |
|---|---|
| CustomerId | INTEGER (Primary Key) |
| FirstName | TEXT |
| LastName | TEXT |
| Column | Type |
|---|---|
| InvoiceId | INTEGER (Primary Key) |
| CustomerId | INTEGER (Foreign Key -> Customer.CustomerId) |
| InvoiceDate | TIMESTAMP |
| Total | NUMERIC(10,2) |
Ready to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.
Run your code to see the result here.