SQL for Analysts

This workshop builds a strong foundation in SQL for data professionals. Starting from basic SELECTs and filtering, we progress through joins, aggregations, subqueries, and window functions. You’ll translate analytical questions into efficient, reusable SQL patterns and practice performance tuning for large datasets in PostgreSQL. The course is hands-on, focused on reporting, product analytics, and BI pipeline scenarios.

PostgreSQL Joins Aggregations Window Functions Performance CTEs
SQL workshop: query patterns, joins, windows

Who it’s for

  • Analysts and product folks moving from ad-hoc queries to robust patterns.
  • BI developers standardizing datasets for dashboards and self-serve.
  • Data teams that want performance discipline and reviewable SQL.

Outcomes

  • Confident with joins, grouping sets, rollups, and windows.
  • Translate business questions to SQL—no spreadsheet crutches.
  • Build reusable CTE-based patterns and safe subqueries.
  • Use EXPLAIN (ANALYZE, BUFFERS) to tune queries.
  • Adopt naming, documentation, and QA habits that stick.

Learning Path

Module 1

SELECT & Filter

Foundation

  • Projection, predicates, WHERE vs HAVING.
  • NULL logic, boolean traps, safe casting.
  • Text/date ops, regex (~) and ILIKE.
  • QA: row-count checks, invariant tests.
Module 2

Joins & Sets

Relational thinking

  • INNER/LEFT/RIGHT/FULL; anti-joins with NOT EXISTS.
  • Set ops: UNION, INTERSECT, EXCEPT.
  • Many-to-many pitfalls; duplicate explosion control.
  • QA: reconciliation tabs, uniqueness tests.
Module 3

Aggregations

From rows to signals

  • GROUP BY, GROUPING SETS, ROLLUP, CUBE.
  • Conditional sums with FILTER clause.
  • Dedup strategies: DISTINCT ON vs window ranks.
  • QA: totals tie-outs and tolerance checks.
Module 4

Subqueries & CTEs

Reusable patterns

  • Scalar, correlated, and lateral (CROSS APPLY-style with LATERAL).
  • CTEs for readability; when to inline for speed.
  • Pattern library: funnels, cohorts, sessionization.
  • QA: golden-input tables for regression.
Module 5

Window Functions

Analytics superpower

  • PARTITION BY, ORDER BY, frames (ROWS/RANGE).
  • LAG/LEAD, running totals, moving averages.
  • Top-N per group with ROW_NUMBER/RANK.
  • QA: edge-window tests around boundaries.
Module 6

Performance

Make it fast

  • Explain plans, nodes, cost vs. time; buffers & I/O.
  • Indexes: B-tree, partial, composite; when not to index.
  • Stats, ANALYZE, vacuum basics; temp tables vs CTE.
  • Anti-patterns: functions on indexed columns, wildcards, carts.

Practicals

  • Reporting: monthly KPI table with rollups and contribution splits.
  • Product analytics: activation funnels, retention cohorts, session windows.
  • BI pipelines: staging → modeling with documented CTEs.
  • Tuning lab: compare plans; rewrite for index use; measure wins.
Cohorts Funnels KPIs EXPLAIN
Explain plan and query rewrite comparison
SQL governance checklist and review workflow

Governance & QA

  • Naming, comments, and docstrings in views/materializations.
  • Peer review checklist: correctness, cardinality, performance.
  • Access tiers: prod read-only vs sandbox; PII minimization.
  • Change control: versioned views, safe deploy, rollback plan.
Standards Review Access Change Control

Format

  • 2 days (or 4× half-days), live + labs.
  • PostgreSQL environment; sample datasets provided.
  • Exercises graded with expected outputs.

Prereqs

  • Basic SQL familiarity helpful but not mandatory.
  • Access to a psql/GUI client (DBeaver, DataGrip, PgAdmin).

Certification

  • Practical assessment: query pack + tuning report.
  • Badge with verifier link and rubric.

Level up your SQL.

Ship queries that are correct, fast, and explainable.