Purpose and vocabulary · Schema, row grain and counts
Beginner5 min read · 5 practice questions
START WITH THE IDEA
Run real SQLite queries, CTEs, subqueries and window functions over fictional financial tables. Row grain: what one database record represents. Join key: field relating records across tables. CTE: named intermediate query introduced with WITH. Result row 1: {"invoice_count":9} Multiplying records through a nonunique join.
Your focus: Run real SQLite queries, CTEs, subqueries and window functions over fictional financial tables.
Learning goals & prerequisites
Learning objectives
- Run real SQLite queries, CTEs, subqueries and window functions over fictional financial tables.
- Apply purpose and vocabulary to SQL focus: Schema, row grain and counts
- Explain the mechanism, perform a check and state a limitation.
Before you begin
- Read the tool labels; basic arithmetic where a calculation is required.
VOCABULARY
Key definitions
- Row grain
- what one database record represents.
- Join key
- field relating records across tables.
- CTE
- named intermediate query introduced with WITH.
METHOD & REASONING
Why this tool and lesson matter
Run real SQLite queries, CTEs, subqueries and window functions over fictional financial tables. Start by identifying the business question this tool answers. A label is useful only when you can explain its meaning and distinguish it from a related concept. Read the worked case without changing its inputs. Identify the resource, obligation, outcome or evidence being measured and the period to which it applies. Explain one definition in your own words, then test that explanation against the supplied example.
A tool can accelerate a method; it cannot choose the business meaning of a field for you.
Vocabulary and field meaning
Row grain: what one database record represents. Join key: field relating records across tables. CTE: named intermediate query introduced with WITH.
The how: an explicit workflow
Inspect invoices, customers and expenses and their keys. Write SELECT columns FROM invoices; use WHERE to filter before aggregation. GROUP BY month produces one aggregate per month; verify SUM(amount) against source totals. Check customer-key uniqueness before JOIN; use CTEs and windows only after the underlying totals reconcile.
Supplied business case
customers — one row per customer Row 1: {"id":1,"name":"Harbor Books","region":"East"} Row 2: {"id":2,"name":"Cedar Coffee","region":"West"} Row 3: {"id":3,"name":"North Studio","region":"East"} invoices — one row per invoice Row 1: {"id":101,"customer_id":1,"month":"2026-01","amount":1200,"status":"paid"} Row 2: {"id":102,"customer_id":2,"month":"2026-01","amount":800,"status":"unpaid"} Row 3: {"id":103,"customer_id":3,"month":"2026-01","amount":1500,"status":"paid"} Row 4: {"id":104,"customer_id":1,"month":"2026-02","amount":1800,"status":"paid"} Row 5: {"id":105,"customer_id":2,"month":"2026-02","amount":950,"status":"unpaid"} Row 6: {"id":106,"customer_id":3,"month":"2026-02","amount":2100,"status":"unpaid"} Row 7: {"id":107,"customer_id":1,"month":"2026-03","amount":1600,"status":"unpaid"} Row 8: {"id":108,"customer_id":2,"month":"2026-03","amount":1100,"status":"paid"} Row 9: {"id":109,"customer_id":3,"month":"2026-03","amount":1700,"status":"paid"} expenses — one row per listed expense Row 1: {"id":1,"month":"2026-01","category":"Payroll","amount":1600} Row 2: {"id":2,"month":"2026-01","category":"Rent","amount":500} Row 3: {"id":3,"month":"2026-02","category":"Payroll","amount":1800} Row 4: {"id":4,"month":"2026-02","category":"Rent","amount":500} Row 5: {"id":5,"month":"2026-03","category":"Payroll","amount":1900} Row 6: {"id":6,"month":"2026-03","category":"Rent","amount":500} Query: SELECT COUNT(*) AS invoice_count FROM invoices; SQL focus: Schema, row grain and counts
Worked query
SELECT COUNT(*) AS invoice_count FROM invoices;Worked method and answer
COUNT(*) counts source records; confirm that an invoice ID is unique before equating records with economic events. Inspect SELECT columns, FROM sources, filtering, grouping and ordering separately. Reconcile the result with the stated source rows. Result row 1: {"invoice_count":9}
The why: interpret and cross-check
COUNT() counts source records; confirm that an invoice ID is unique before equating records with economic events. The data is fictional and statements about cash, revenue recognition or business quality need separate evidence. SELECT COUNT() AS invoice_count FROM invoices; COUNT(*) counts source records; confirm that an invoice ID is unique before equating records with economic events.
Guided application in the tool
Open Advanced SQL Lab using the Use tool option. Read the labels and enter only the supported values or evidence from this case. Try to predict the result before calculating or revealing worked reasoning. For a writing task, draft your own explanation and compare it with the stated review criteria. Record the source, period and assumptions. Preserve the original example and note any changed inputs. Use your conclusion or reflection area to explain what the result means, then save the workspace if signed in.
Independent task and review criteria
Start by identifying the business question this tool answers. A label is useful only when you can explain its meaning and distinguish it from a related concept. Read the worked case without changing its inputs. Identify the resource, obligation, outcome or evidence being measured and the period to which it applies. Explain one definition in your own words, then test that explanation against the supplied example. A tool can accelerate a method; it cannot choose the business meaning of a field for you.
A strong submission identifies the business question, uses the supplied facts consistently, shows the method, performs a useful independent check and acknowledges a condition that could change the conclusion. A correct number alone is incomplete; explain its unit and business mechanism. Separate a future assumption from an observed outcome and avoid claiming a credential from a practice result.
Common mistake
Multiplying records through a nonunique join.
Scope, assumptions and limitations
Read-only SQLite with fictional tables, a fresh database per run and 500 displayed rows. No access to account databases or outside systems. Read-only SQLite with fictional tables, a fresh database per run and 500 displayed rows. No access to account databases or outside systems.
FORMULA TOOLKIT
SEE IT IN ACTION
Worked examples
Worked example 1 · Start here
customers — one row per customer Row 1: {"id":1,"name":"Harbor Books","region":"East"} Row 2: {"id":2,"name":"Cedar Coffee","region":"West"} Row 3: {"id":3,"name":"North Studio","region":"East"} invoices — one row per invoice Row 1: {"id":101,"customer_id":1,"month":"2026-01","amount":1200,"status":"paid"} Row 2: {"id":102,"customer_id":2,"month":"2026-01","amount":800,"status":"unpaid"} Row 3: {"id":103,"customer_id":3,"month":"2026-01","amount":1500,"status":"paid"} Row 4: {"id":104,"customer_id":1,"month":"2026-02","amount":1800,"status":"paid"} Row 5: {"id":105,"customer_id":2,"month":"2026-02","amount":950,"status":"unpaid"} Row 6: {"id":106,"customer_id":3,"month":"2026-02","amount":2100,"status":"unpaid"} Row 7: {"id":107,"customer_id":1,"month":"2026-03","amount":1600,"status":"unpaid"} Row 8: {"id":108,"customer_id":2,"month":"2026-03","amount":1100,"status":"paid"} Row 9: {"id":109,"customer_id":3,"month":"2026-03","amount":1700,"status":"paid"} expenses — one row per listed expense Row 1: {"id":1,"month":"2026-01","category":"Payroll","amount":1600} Row 2: {"id":2,"month":"2026-01","category":"Rent","amount":500} Row 3: {"id":3,"month":"2026-02","category":"Payroll","amount":1800} Row 4: {"id":4,"month":"2026-02","category":"Rent","amount":500} Row 5: {"id":5,"month":"2026-03","category":"Payroll","amount":1900} Row 6: {"id":6,"month":"2026-03","category":"Rent","amount":500} Query: SELECT COUNT() AS invoice_count FROM invoices; COUNT() counts source records; confirm that an invoice ID is unique before equating records with economic events.
Inspect SELECT columns, FROM sources, filtering, grouping and ordering separately. Reconcile the result with the stated source rows. Result row 1: {"invoice_count":9}
Check your understanding · 5 questions
Try each question before reading its solution. Guests can check the first three questions. Sign in to save your answers or try the full set. Written responses use self-review.
How to review a written answer
Check your response against the returned model reasoning and each required step. Name a supplied fact, show how it supports the method, and state the conclusion’s limitation. A response that only repeats a definition is incomplete. Written submission is recorded as self-review, not automatically correct.
Predict, explore, and explain
Before revealing the method, predict the result or the approach you would use. Compare your reasoning after you explore.
Test your reasoning against a worked example
Explain it in your own words
STRUCTURED SELF-REVIEW
Close the worked example. Explain the idea, describe why the method works, and give a small business example. Then reopen the lesson to check your reasoning. This is a self-review rubric; no AI analysis or automatic writing score is provided.
Open this section to load the lesson rubric.
TAKE THE NEXT STEP
Use it once. Then explain why.
You’ve explored purpose and vocabulary · schema, row grain and counts. Now check what you can explain and apply without the worked answer.
- Recall the idea. Explain when you would use this method and what its answer means.
- Try it independently. Work through a practice question before revealing help.
- Review the reasoning. Compare your method with the feedback, then revisit any saved mistakes.
Ask about a step in this lesson
Build a short review routine
- Close the explanation and describe the main idea in one sentence.
- Work through a question and state why you chose the method.
- Compare your reasoning with the feedback; record what you would change.
- Return later and try a question again before reading your notes.
Marking a lesson as read tracks your place. Practice results track your answers.
Loading saved progress…