🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 89:

Sales Order Summary

SQL Server 2022
The finance team wants one line with the key figures of all orders in the SalesOrderHeader table.
Output the columns orders (the number of orders), customers (the number of different customers), revenue (the sum of TotalDue), avg_order (the average TotalDue, rounded to 2 decimal places), smallest_order and largest_order (the smallest and the largest TotalDue).
Expected result Columns: 6 · Rows: 1
orders customers revenue avg_order smallest_order largest_order

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

The query result will appear here. Ctrl+Enter - Run query