Free practice · Interactive SQL · medium
Practice
Reconcile order control totals
Return order_count, distinct_order_count, and total_revenue using COUNT(*), COUNT(DISTINCT order_id), and SUM(order_amount).
Table relationshipsemployees.manager_id→employees.employee_idorders.customer_id→customers.customer_idorders.sales_rep_id→employees.employee_idorder_items.order_id→orders.order_idorder_items.product_id→products.product_id
customers
Customer profile fields used for account reporting.
6 rowsGrain One row per customer
customer_idTEXTPKcustomer_nameTEXTcityTEXTstate_codeTEXTsegmentTEXTsignup_dateTEXT
Preview source rows
employees
Sales employees and their reporting relationships.
5 rowsGrain One row per employee
employee_idTEXTPKemployee_nameTEXTregionTEXTmanager_idTEXTFK
Preview source rows
products
Products available in the fictional US service catalog.
4 rowsGrain One row per product
product_idTEXTPKproduct_nameTEXTcategoryTEXTactive_flagINTEGER
Preview source rows
orders
Order-level dates, statuses, owners, and USD amounts.
7 rowsGrain One row per order
order_idTEXTPKcustomer_idTEXTFKorder_dateTEXTstatusTEXTsales_rep_idTEXTFKorder_amountREAL
Preview source rows
order_items
Product lines belonging to customer orders.
7 rowsGrain One row per product on an order
order_idTEXTFKproduct_idTEXTFKquantityINTEGERunit_priceREALdiscount_pctREAL
Preview source rows
Changes to this practice database are never saved.
Ready to check your work?Edit the starter query, run it, then compare your result with the task.