SQL Practice Dashboard

Practice SQL by hand, even though agents will make this obsolete.

0 / 25 solved
Loading the database…
Tables
SQLite vs SQL Server (Azure SQL) vs PostgreSQL
TaskSQLite (this page)SQL Server / Azure SQLPostgreSQL
First 10 rowsLIMIT 10SELECT TOP 10 … or OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLYLIMIT 10
Month bucketstrftime('%Y-%m', ts)FORMAT(ts, 'yyyy-MM') or DATEFROMPARTS(YEAR(ts), MONTH(ts), 1)to_char(ts, 'YYYY-MM') or date_trunc('month', ts)
Add 7 daysdate(d, '+7 day')DATEADD(day, 7, d)d + interval '7 days'
Hours between(julianday(b) - julianday(a)) * 24DATEDIFF(hour, a, b), which counts hour boundaries crossedextract(epoch from b - a) / 3600
Nowdatetime('now')GETDATE() or SYSUTCDATETIME()now()
NULL fallbackCOALESCE(x, 0) or IFNULLCOALESCE(x, 0) or ISNULL(x, 0)COALESCE(x, 0)
Inline ifCASE WHEN … or iif()CASE WHEN … or IIF()CASE WHEN …
Join stringsa || ba + b or CONCAT(a, b)a || b or concat(a, b)
Integer division7 / 2 = 3; use 7.0 / 27 / 2 = 3; use 7.0 / 2 or CAST7 / 2 = 3; use 7.0 / 2 or ::numeric
Recursive CTEWITH RECURSIVEWITH (no RECURSIVE keyword)WITH RECURSIVE
90th percentileNo built-in; rank rows yourselfPERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY x) OVER ()percentile_cont(0.9) WITHIN GROUP (ORDER BY x)
Booleans0 / 1 integersBITboolean
UpsertINSERT … ON CONFLICT DO UPDATEMERGEINSERT … ON CONFLICT DO UPDATE

Your answers

Every problem you solved, as you wrote it. Save this as solutions/<your-name>.sql and commit it so your practice shows in the repo history.

Mock test