SQL for business analysts
Ask a database real questions: select, join and group, handle nulls, find doubles, change data safely and read a query plan.
- Tables, rows, columns and keys: what a database holdsBefore any query, see what a database actually holds. Learn what a table, a row and a column are, why each column has a type, and how an id column names each row.
- SQL for BAs: SELECT and WHEREAsk a database questions with SELECT and WHERE. Learn conditions, null, sorting, limits, the second-highest trick, the five kinds of SQL statement and safe habits for analysts.
- SQL (Structured Query Language) for BAs: filters, sorting and totalsMost analyst questions are a filter, an order and a total. Learn IN, BETWEEN and LIKE, then ORDER BY, LIMIT, DISTINCT and the five totals.
- Patterns, lists, ranges and aliases: LIKE, IN, BETWEEN and ASFilter by a pattern, a list or a range, give columns and tables short names, and learn the order a query really runs in, which explains most first errors.
- SQL for BAs: NULL and missing valuesMissing values change counts, sums and filters. Learn how NULL behaves so your numbers match what the business expects.
- SQL (Structured Query Language) for BAs: CRUD (create, read, update, delete), from a requirement to four statementsEvery screen action is create, read, update or delete. Learn how each one becomes a SQL (Structured Query Language) statement so you can write and check requirements.
- SQL (Structured Query Language) for BAs: INSERT, UPDATE and DELETE, read before you writeAnalysts mostly read data, but sometimes change it. Learn what these statements do, why a missing WHERE is dangerous and how to ask for changes safely.
- Totals in plain words: count, SUM (add up), AVG (average), MIN (smallest) and MAX (largest)Learn the five total functions one at a time, what each does with missing values, what they return on an empty table, and how to check a total against a count you trust.
- SQL for BAs: GROUP BY and countsCount and total rows in groups with GROUP BY. Learn HAVING, nulls, duplicates, monthly counts, funnels, ranking, top-N, running totals and a first look at WITH.
- Aggregation in depth: HAVING, distinct counts and grouping levelsCounting is more than counting every row. Learn where a filter goes before or after grouping, how distinct counts differ, and how to add subtotal rows.
- Conditional totals and pivot-style reports in a queryGroup many rows into one line each, with a column per status. Learn conditional totals with CASE (a rule-based choice) and a row filter, and when a pivot report fits.
- SQL for BAs: JOINCombine two tables with JOIN. Learn keys, the difference between INNER and LEFT joins, how to find rows with no match, double rows, and what to ask when a query is slow.
- Join types in depth: inner, left, full, cross and selfOne word changes the answer. Learn what each join keeps and drops, how to read the row counts, and why a filter in the wrong place quietly changes the join.
- Join fan-out: why a total comes out too bigA join can repeat a row once for every match, and a sum then counts it again. Learn the grain of a table, how to spot the repeat, and three safe fixes.
- Anti-joins: finding what has no matchWhich users have no task? Which tasks have no owner? Learn three ways to ask, and why one of them, NOT IN, can quietly return nothing when a null is present.
- SQL for BAs: UNION, EXCEPT and EXISTSSometimes the question is which rows are in one list and not in another. Learn the set operators and EXISTS, and the traps that come with them.
- SQL for BAs: subqueries and common table expressionsAnswer two-step questions in SQL, such as the second-highest value or duplicate rows, with a query inside a query or with named steps, and know which to pick.
- SQL for BAs: CASE, dates and textReal data needs grouping into bands, cleaning text and working with dates. Learn the small functions that do most of the work.
- CREATE, ALTER and DROP: making and changing tablesSee how a table is made, changed and removed, what a data type and a default do when you define a column, and why a drop is the one statement to treat with care.
- SQL for BAs: statement types, keys and constraintsKnow the five families of SQL statements, the difference between a primary key and a unique key, and the rules a database enforces on its own.
- Keys and normal formsSee why a table should hold each fact once, how first, second and third normal form get there, and when a team repeats data on purpose to read faster.
- Databases for analysts: indexes, views, locks and transactionsKnow what an index, a view and a transaction do, how locks keep writers apart, and which questions to ask when a report is slow or a change stops half way.
- Finding duplicates and bad rows with a queryDuplicates and missing links are the most common data problems. Learn the group and count check, the join check for orphans, and how to report what you find.
- SQL for BAs: window functions and rankingRank rows inside groups, pick the top row per group, and decide in advance how ties are treated, using ROW_NUMBER, RANK and DENSE_RANK.
- Window functions in depth: frames, lag and lead, and top N per groupGo past ranking. Learn what a frame of rows is, how to compare a row with the one before it, and how to keep the top few rows in each group.
- SQL for BAs: running totals, month-on-month change and streaksWrite a running total or a moving average, compare one month with the last using LAG, find days in a row, and say why the frame of a window should be spelled out.
- SQL for BAs: funnels, cohorts and retentionCount users at each funnel step and the share each cohort keeps, in SQL, and check the counts so that no user is counted twice.
- SQL for BAs: comparing two sources (reconciliation)Two systems should agree, and often do not. Learn the usual steps to match two lists, find what is missing on each side and find values that differ.
- SQL (Structured Query Language) for BAs: when the same query behaves differentlySQL is a standard, but each database adds its own words and rules. Learn what usually differs so a query that works in one place does not surprise you in another.
- SQL for BAs: why a query is slowA slow query costs time and can hurt a busy system. Learn the few causes you can spot and how to ask for help with a plan.