SQL · Module 1
Answers and explanations · Start with a question and a safe lab
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
SQL · Module 1
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
Both counts are 14. This supports unique non-null order identifiers in the observed table. It does not prove that every real-world order was loaded or that the selected population is correct.
SELECT COUNT(*) AS rows,COUNT(DISTINCT order_id) AS distinct_orders FROM aabha_sql.orders;
Expected output:
| rows | distinct_orders |
|---|---|
| 14 | 14 |
Runnable answer: sql/solutions/01a.sql
There are 19 lines for 14 orders because some baskets contain two product lines. A count at line grain is not an order count.
SELECT COUNT(*) AS order_lines FROM aabha_sql.order_items;
Expected output:
| order_lines |
|---|
| 19 |
Runnable answer: sql/solutions/01b.sql