// authors
SQL articles and tutorials by SqlInt team — 37 articles.
This is the retail and e-commerce interview classic: find product pairs frequently bought together. One line of self-join logic makes or breaks the answer.
YoY growth questions test whether a candidate reaches for LAG or a clunky self-join, and whether they remember to guard against divide-by-zero. A full walkthrough with both engines.
Retention questions are a growth team staple in SQL interviews. This walks through the exact query, the schema, and the integer division bug that quietly wrecks an otherwise correct solution.
Window functions are the single most common topic in SQL interviews that separates candidates who understand real analytics from those who only know basic SELECT statements. Here is the exact rolling average question interviewers ask, solved in SQLite and PostgreSQL.
A single-page SQL reference covering JOINs, window functions, CTEs, NULL handling, CASE WHEN, string/date functions, constraints, common query patterns, and more.
Learn how SQL injection attacks actually work — authentication bypass, UNION-based data exfiltration — and how parameterized queries prevent them structurally.
Learn to write idempotent SQL for migrations, seed scripts, and ETL jobs — safe upserts, guarded schema changes, and the relative-update trap that compounds on re-run.
Learn to build Recency, Frequency, Monetary (RFM) customer segmentation in SQL using NTILE, including the recency-inversion gotcha and segment-level reporting.
Learn to analyze A/B tests in SQL — conversion rate by variant, sample ratio mismatch checks, a two-proportion z-test, and common statistical pitfalls like peeking.
A practical decision framework for choosing between a CTE, subquery, temp table, view, or materialized view in SQL, with a comparison table and real tradeoffs.
Go beyond basic CASE WHEN syntax — conditional aggregation, custom ORDER BY logic, NULL-safe bucketing, and the equivalence between CASE, COALESCE, and NULLIF.
Understand SQL three-valued logic and NULL handling in depth — COALESCE, NULLIF, IS NULL, NULLs in joins and aggregates, and the dangerous NOT IN + NULL trap.
A side-by-side guide to SQL date and time functions across PostgreSQL, MySQL, and SQL Server — DATE_TRUNC, DATEADD, EXTRACT, and the timezone pitfalls that cause bugs.
A practical guide to SQL string functions — CONCAT, SUBSTRING, TRIM, REPLACE, and REGEXP — with a real data-cleaning example and the CONCAT vs || NULL-handling difference.
A practical guide to choosing between SQL and NoSQL — document, key-value, column-family, and graph databases compared, plus polyglot persistence and common anti-patterns.
A deep dive into SQL transactions and ACID properties, isolation levels and the phenomena they prevent, pessimistic vs optimistic locking, and deadlock prevention.
A deep dive into 1NF/2NF/3NF with real update/insert/delete anomalies, plus when and how to denormalize using duplicated columns, materialized views, and star schemas.
A deep dive into how SQL indexes actually work — B-tree internals, composite index column order, covering indexes, partial indexes, and the write-performance tradeoff.
Learn the three core product analytics SQL patterns — funnel analysis, retention (Day-1/7/30), and cohort analysis — using a standard events table, with common mistakes explained.
Big tech SQL interviews draw from six recurring patterns, not company-specific question banks. Learn to recognize ranking, funnels, streaks, hierarchies, dedup, and schema design questions.
Understand the real difference between CHAR, VARCHAR, and TEXT in SQL — storage mechanics, performance across PostgreSQL/MySQL/SQL Server, and when to use each type.
A complete guide to SQL constraints — PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL, and DEFAULT — with ON DELETE CASCADE behavior and how to add constraints safely.
A practical SQL data types reference covering numeric, string, date/time, boolean, and JSON types across PostgreSQL, MySQL, and SQL Server, with a type-selection checklist.
Understand exactly how WHERE, GROUP BY, and HAVING execute in SQL, with the real logical execution order, common mistakes, and why filtering early with WHERE is faster.
Learn SQL subqueries from the ground up — correlated vs non-correlated, where subqueries can appear, and when to use a subquery vs a JOIN vs EXISTS, with the NOT IN NULL trap explained.
Learn every way to solve top N per group in SQL — ROW_NUMBER, RANK, DENSE_RANK, correlated subqueries, and LATERAL/CROSS APPLY — with performance tradeoffs explained.
Learn to calculate running totals, moving averages, and percent-of-total in SQL using window functions and frame clauses, with common mistakes and date-gap handling.
Learn recursive CTEs from the ground up — anchor and recursive members, org chart traversal, bill-of-materials explosions, date spine generation, and cycle prevention.
A complete guide to SQL window functions — RANK, DENSE_RANK, ROW_NUMBER, LAG/LEAD, NTILE, and aggregate window functions, with frame clauses and performance notes explained.
The definitive guide to finding the Nth highest salary in SQL — OFFSET/LIMIT, correlated subqueries, and DENSE_RANK, with correct tie-handling and top-N-per-group variants.
Learn how to pivot and unpivot data in SQL using CASE, FILTER, and PIVOT/UNPIVOT operators, plus dynamic pivoting and when to reshape data in SQL vs. the application layer.
Five proven ways to find duplicate rows in SQL — GROUP BY, self joins, window functions, EXISTS, and COUNT() OVER — plus how to safely delete duplicates and prevent them.
Learn how self joins work with employee-manager hierarchies, org charts, and recursive CTEs, plus common mistakes and real interview questions on this classic SQL pattern.
Master the gaps and islands SQL interview pattern — find consecutive streaks and missing values using ROW_NUMBER, LAG, and running-sum techniques, with database compatibility notes.
Prepare for your SQL interview with all 20 essential questions covering joins, window functions, CTEs, indexing, transactions, and optimization, plus 5 bonus practical query challenges.
A complete guide to SQL JOINs with practical examples, performance notes, and common mistakes. Covers INNER, LEFT, RIGHT, FULL OUTER, CROSS, self joins, and semi/anti-joins.
Master SQL query optimization with 10 proven techniques, from indexing and execution plans to sargability and keyset pagination. Includes a practical optimization checklist and FAQ.