Manuals / Data Literacy / Ch 4

B · QueryIntermediate40 min read

4. SQL lite for truth-seeking

Data Literacy · 32 pages source format

SELECT, WHERE, GROUP BY, COUNT, averages. Enough to verify a dashboard number once.

What you'll learn

  • Aggregations
  • Joins caution
  • Sampling

Reproduce a number

SELECT date_trunc('day', created_at) AS day,
       COUNT(*) FILTER (WHERE status = 'error') AS errors,
       COUNT(*) AS total
FROM events
WHERE created_at >= now() - interval '7 days'
GROUP BY 1
ORDER BY 1;

Do this now

Match (or explain mismatch of) one dashboard figure with a query or export.

Clear?

Checklist