Section 6: Lab: Subqueries, CTEs and Window Functions
- Types of subquery, and chained CTEs (WITH) that break a big question into readable steps
- Use UNION and EXCEPT to compare two sets of data
- OVER, PARTITION BY and ORDER BY in plain language
- ROW_NUMBER, RANK and DENSE_RANK to rank rows and find the latest row in each group
- LAG, LEAD, running totals and moving averages to compare periods and spot trends
- Use window functions to find duplicates that should exist only once
Section 7: Data Profiling: Know Your Data Before You Trust It
- Completeness: the share of missing values in each column
- Uniqueness: duplicates that should not exist, such as member card numbers or product codes
- Consistency: orphan records that point to data that does not exist
- Plausibility: negative values, future dates and values outside the allowed range
- A standard data quality report you can reuse on every project
Section 8: Systematic Root Cause Investigation
- Form a hypothesis, design a query to test it and summarise the evidence
- Trace discrepancies in figures between two systems
- Check the history of data changes through audit log tables
- Write a one-page investigation summary that management can follow
Section 9: Query Performance and Safety
- Read EXPLAIN at a basic level: sequential scan versus index scan
- Query patterns that stop an index from being used, and how to avoid them
- Good practice when you have to query a production system
- PDPA: mask personal data before sharing results with others
Section 10: Lab: From Results to a Report You Can Present
- Export results to Excel or CSV correctly
- Build questions and a dashboard in Metabase from your own SQL
- Set up filters and parameters so business users can view the report themselves
Section 11: Master Workshop: NovaRetail Data Investigation
- Find out why the sales report does not match the store figures
- Check for duplicates, orphan records and cancelled orders still being counted
- Produce a data quality report with findings and recommendations, and present it to the group