Loading…
Loading…
SQL
A complete SQL course for students and working developers: queries, joins, aggregation, subqueries, window functions, data changes, types and functions, reporting, design, DDL, indexes, security, transactions, procedural SQL, performance and graded exercises. 72 articles with practice quizzes.
How the frame clause decides which rows a window aggregate sees: running and reverse totals, cumulative percentages, trailing and centred moving averages, ROWS versus RANGE versus GROUPS and how they treat gaps and ties, the default frame, EXCLUDE, and support in each database.
kvi5hnuCode Sprout team member13 minHow SQL's ranking window functions number and rank rows: ROW_NUMBER, RANK and DENSE_RANK and how they treat ties, NTILE buckets, PERCENT_RANK and CUME_DIST, top-N per group, keeping ties with FETCH FIRST WITH TIES, removing duplicates, and making rankings deterministic.
kvi5hnuCode Sprout team member11 minHow window functions compute values across related rows without collapsing them: the OVER clause, PARTITION BY, ORDER BY and running totals, the default frame and ties, where windows run in a query, why they can't go in WHERE, windows over grouped rows, and named windows.
kvi5hnuCode Sprout team member11 minHow WITH RECURSIVE builds a result step by step: the anchor and recursive parts, how execution stops, generating number and date series, walking a hierarchy down and up, tracking depth and paths, avoiding infinite loops in graphs, the CYCLE and SEARCH clauses, and dialect limits.
kvi5hnuCode Sprout team member14 minHow the WITH clause names intermediate results so a complex query reads top to bottom: syntax, chaining and reusing CTEs, scope rules, CTEs versus derived tables and views, materialization and performance, data-modifying CTEs in PostgreSQL, and dialect differences.
kvi5hnuCode Sprout team member12 minSubqueries that depend on the outer row: how correlated subqueries are evaluated, the name-resolution trap that silently matches every row, derived tables in FROM, and LATERAL joins (CROSS APPLY in SQL Server) for top-N per group and per-row calculations.
kvi5hnuCode Sprout team member14 minHow to use a query inside another query: scalar subqueries that return one value, IN and EXISTS subqueries that test membership, comparisons with ANY and ALL, subqueries in SELECT, FROM and HAVING, and the edge cases with empty results and NULLs that catch people out.
kvi5hnuCode Sprout team member16 minHow to compute several conditional counts and totals in one pass with CASE inside COUNT and SUM, and with the standard FILTER clause: the ELSE 0 counting bug, percentages and shares, rows into columns, conditions on groups in HAVING, and what each database supports.
kvi5hnuCode Sprout team member13 minHow to get detail rows, subtotals and a grand total from one query with ROLLUP, CUBE and GROUPING SETS: how each expands into grouping sets, telling subtotal NULLs from real NULLs with GROUPING(), labelling and sorting totals, partial rollups, and MySQL's WITH ROLLUP.
kvi5hnuCode Sprout team member13 minHow GROUP BY splits rows into groups and computes aggregates for each one, and how HAVING filters the groups: the SELECT-list rule, NULL groups, grouping by expressions and dates, counting with outer joins, WHERE versus HAVING, and finding duplicates.
kvi5hnuCode Sprout team member16 minHow SQL's aggregate functions turn many rows into one value: COUNT(*) versus COUNT(column), DISTINCT inside aggregates, how NULLs are skipped, empty inputs, integer averages, result types, and the errors you get when mixing aggregates with plain columns.
kvi5hnuCode Sprout team member18 minJoin mistakes that give wrong numbers without any error: fan-out when one row joins several child tables, inflated SUMs, why DISTINCT is no fix, checking a join's grain, partial keys and mismatched types, and comparing two tables to find added, removed and changed rows.
kvi5hnuCode Sprout team member12 minHow to ask "does a related row exist?" without duplicating rows: semi-joins with EXISTS and IN, anti-joins with NOT EXISTS, LEFT JOIN ... IS NULL and EXCEPT, the NOT IN trap with NULLs, correlated conditions inside EXISTS, and how databases execute these queries.
kvi5hnuCode Sprout team member10 minHow to combine the results of several queries: UNION and UNION ALL to stack rows, INTERSECT for rows in both, EXCEPT (MINUS in Oracle) for rows in one but not the other, the ALL variants, the column and type rules, ORDER BY and LIMIT with set operations, precedence, NULL handling and performance.
kvi5hnuCode Sprout team member9 minThree joins that go beyond matching a foreign key to a primary key: self joins for relationships inside one table, CROSS JOIN for every combination of two sets, and non-equi joins that match rows by ranges, bands, dates and inequalities, including triangular joins and how fast they grow.
kvi5hnuCode Sprout team member10 minHow outer joins keep rows that have no match: LEFT, RIGHT and FULL JOIN, the NULLs they produce, finding rows without a partner, why a WHERE condition can silently turn an outer join into an inner join, chains of outer joins, and Oracle's old (+) syntax.
kvi5hnuCode Sprout team member10 minHow INNER JOIN combines rows from two or more tables: the ON condition, table aliases, qualified and ambiguous column names, joining three or four tables, USING and NATURAL JOIN, the old comma syntax, joins on non-key columns, and why rows without a match disappear.
kvi5hnuCode Sprout team member12 minHow to write if-then-else logic inside a query: searched and simple CASE, why WHEN order matters, the missing ELSE, NULL in simple CASE, type rules, CASE in ORDER BY, WHERE and aggregates (conditional counts and pivots), FILTER, and shorthand functions such as COALESCE, GREATEST and LEAST.
kvi5hnuCode Sprout team member11 minRemoving duplicate rows with DISTINCT (and PostgreSQL's DISTINCT ON), limiting results with FETCH FIRST, LIMIT, TOP and ROWNUM, WITH TIES, OFFSET, and the two ways to paginate: OFFSET, which gets slower on every page, and keyset pagination, which doesn't.
kvi5hnuCode Sprout team member11 minHow ORDER BY works and why rows have no order without it: ascending and descending keys, sorting by several columns, aliases and expressions, where NULLs go and how to move them, custom and data-dependent orders with CASE, natural sorting of codes, collations and ties.
kvi5hnuCode Sprout team member10 min