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.
Working with trees in SQL: displaying a hierarchy depth-first with paths and indentation, roots, branches and leaves, rolling totals up a tree, closure tables, materialised paths and ltree, flattening levels into columns, and Oracle's CONNECT BY.
kvi5hnuCode Sprout team member10 minSearch patterns in SQL: the row holding a maximum per group four ways and how they treat ties, the nth highest value, the cheapest and dearest in one row, GREATEST and LEAST, as-of lookups in a history table, nearest values, and skipping rows.
kvi5hnuCode Sprout team member10 minReport-building techniques in SQL: grouping values into bands with CASE, WIDTH_BUCKET and NTILE, text histograms, percentages of a total and of a group, running percentages and ABC analysis, top N with an "other" row, and labelled subtotal reports with ROLLUP.
kvi5hnuCode Sprout team member9 minHow to unpivot in SQL: UNION ALL, a lateral VALUES list, unnest, the UNPIVOT operator in SQL Server and Oracle, handling NULLs and mixed column types, unpivoting every column through JSON, and re-pivoting data into a different shape.
kvi5hnuCode Sprout team member7 minHow to pivot in SQL: conditional aggregation with FILTER and CASE, zeros and totals, pivoting by position, PostgreSQL's crosstab, the PIVOT operator in SQL Server and Oracle, dynamic pivots when the columns aren't known in advance, and JSON as a flexible alternative.
kvi5hnuCode Sprout team member9 minHow to work with JSON in SQL databases: json versus jsonb, extracting values with -> and ->>, containment and existence tests, turning arrays into rows, JSON_TABLE and the SQL/JSON path functions, building JSON from rows, updating documents, indexing, and when JSON is the wrong choice.
kvi5hnuCode Sprout team member11 minPattern matching beyond LIKE: regular expression syntax, matching with ~ and REGEXP_LIKE, extracting matches and capture groups, replacing with back-references, validating values with CHECK constraints, greedy and lazy quantifiers, splitting on patterns, and the differences between databases.
kvi5hnuCode Sprout team member10 minCalendar techniques in SQL: first and last day of a month or quarter, leap years, generating date series, filling missing dates with zeros, a calendar table with holidays, the nth weekday of a month, and printing a month calendar.
kvi5hnuCode Sprout team member9 minHow to calculate with dates in SQL: adding days, months and years, what happens at the end of a month, differences in days, hours, months and years, AGE, working days, deadlines, overlapping periods, date ranges in WHERE, and DATEADD, DATEDIFF and their equivalents in each database.
kvi5hnuCode Sprout team member10 minHow SQL represents dates and times: DATE, TIME, TIMESTAMP and TIMESTAMP WITH TIME ZONE, literals, the current date and time, EXTRACT and DATE_TRUNC, formatting and parsing with TO_CHAR and TO_DATE, time zones and AT TIME ZONE, daylight saving time, and the equivalents in each database.
kvi5hnuCode Sprout team member12 minWorking with numbers in SQL: ROUND, TRUNC, FLOOR and CEIL and how each rounds negative values and halves, safe division with NULLIF, percentages of a total, median and percentiles with PERCENTILE_CONT and PERCENTILE_DISC, the mode, standard deviation and z-scores, and the other math functions.
kvi5hnuCode Sprout team member12 minPractical techniques for text in SQL: splitting strings with SPLIT_PART and string_to_table, turning rows into lists with STRING_AGG, GROUP_CONCAT and LISTAGG, turning lists back into rows, counting occurrences, walking a string character by character, and sorting text that holds numbers.
kvi5hnuCode Sprout team member10 minThe everyday SQL string functions and how they differ between databases: length in characters and bytes, UPPER, LOWER and INITCAP, concatenation and NULL, SUBSTRING, LEFT, RIGHT and POSITION, TRIM, REPLACE and TRANSLATE, padding and FORMAT, case-insensitive comparison and collations.
kvi5hnuCode Sprout team member12 minA practical guide to SQL data types: integers, DECIMAL versus floating point, CHAR, VARCHAR and TEXT, dates and times, booleans, binary data, how type names differ between databases, CAST and implicit conversion, integer division, rounding on conversion and checking conversions safely.
kvi5hnuCode Sprout team member14 minHow to insert a row or update it if it exists: ON CONFLICT and EXCLUDED, MySQL's ON DUPLICATE KEY UPDATE, MERGE with MATCHED, NOT MATCHED and NOT MATCHED BY SOURCE, RETURNING and OUTPUT, data-modifying CTEs, and concurrency.
kvi5hnuCode Sprout team member13 minHow to remove rows safely: DELETE with WHERE, foreign keys that block deletes, deleting with subqueries and joins, archiving before deleting, TRUNCATE and how it differs from DELETE, finding and removing duplicate rows with ROW_NUMBER, soft deletes and large batch deletes.
kvi5hnuCode Sprout team member11 minHow to change existing rows with UPDATE: SET and WHERE, expressions that use the old values, CASE for different changes per row, correlated subqueries and the NULL trap, UPDATE with joins in each database, constraints, NULL handling and how to update safely.
kvi5hnuCode Sprout team member11 minHow to add rows to a table with INSERT: listing columns, inserting several rows at once, defaults and the DEFAULT keyword, identity columns, constraint errors and all-or-nothing statements, type conversion, INSERT ... SELECT, CREATE TABLE AS, and bulk loading in each database.
kvi5hnuCode Sprout team member12 minHow to solve gaps-and-islands problems in SQL with window functions: finding missing dates and IDs, grouping consecutive days into ranges, user streaks, runs of the same status, splitting events into sessions, and merging overlapping date ranges.
kvi5hnuCode Sprout team member11 minHow to read values from other rows of a window: LAG and LEAD for the previous and next row, offsets and defaults, day-over-day changes and gaps between events, FIRST_VALUE, LAST_VALUE and NTH_VALUE and the frame trap, and filling gaps with the last known value, with or without IGNORE NULLS.
kvi5hnuCode Sprout team member11 min