Northwind › SQL Console
SQL Console
Type a SELECT and run it against the Northwind database. This is SQLite 3.45, so SQLite's own functions, window functions, recursive CTEs, EXPLAIN QUERY PLAN and PRAGMA table_info(…) all work. Table names that contain a space need double quotes: "Order Details".
Result
| OrderID | ProductID | ProductName | UnitPrice | Quantity | Discount | ExtendedPrice |
|---|---|---|---|---|---|---|
| 10265 | 17 | Alice Mutton | 31.2 | 30 | 0.0 | 936.0 |
| 10279 | 17 | Alice Mutton | 31.2 | 15 | 0.25 | 351.0 |
| 10294 | 17 | Alice Mutton | 31.2 | 15 | 0.0 | 468.0 |
| 10302 | 17 | Alice Mutton | 31.2 | 40 | 0.0 | 1248.0 |
| 10319 | 17 | Alice Mutton | 31.2 | 8 | 0.0 | 249.6 |
| 10338 | 17 | Alice Mutton | 31.2 | 20 | 0.0 | 624.0 |
| 10339 | 17 | Alice Mutton | 31.2 | 70 | 0.05 | 2074.8 |
| 10346 | 17 | Alice Mutton | 31.2 | 36 | 0.1 | 1010.88 |
| 10415 | 17 | Alice Mutton | 31.2 | 2 | 0.0 | 62.4 |
| 10430 | 17 | Alice Mutton | 31.2 | 45 | 0.2 | 1123.2 |
| 10431 | 17 | Alice Mutton | 31.2 | 50 | 0.25 | 1170.0 |
| 10444 | 17 | Alice Mutton | 31.2 | 10 | 0.0 | 312.0 |
| 10523 | 17 | Alice Mutton | 39.0 | 25 | 0.1 | 877.5 |
| 10530 | 17 | Alice Mutton | 39.0 | 40 | 0.0 | 1560.0 |
| 10550 | 17 | Alice Mutton | 39.0 | 8 | 0.1 | 280.8 |
| 10564 | 17 | Alice Mutton | 39.0 | 16 | 0.05 | 592.8 |
| 10573 | 17 | Alice Mutton | 39.0 | 18 | 0.0 | 702.0 |
| 10607 | 17 | Alice Mutton | 39.0 | 100 | 0.0 | 3900.0 |
| 10686 | 17 | Alice Mutton | 39.0 | 30 | 0.2 | 936.0 |
| 10696 | 17 | Alice Mutton | 39.0 | 20 | 0.0 | 780.0 |
| 10698 | 17 | Alice Mutton | 39.0 | 8 | 0.05 | 296.4 |
| 10714 | 17 | Alice Mutton | 39.0 | 27 | 0.25 | 789.75 |
| 10727 | 17 | Alice Mutton | 39.0 | 20 | 0.05 | 741.0 |
| 10773 | 17 | Alice Mutton | 39.0 | 33 | 0.0 | 1287.0 |
| 10795 | 17 | Alice Mutton | 39.0 | 35 | 0.25 | 1023.75 |
Example queries
Row countsUNION ALL stacks five counts into one result.
Order Details columnspragma_table_info shows the two-column primary key.
Territories per employeeFour tables joined through a junction table.
Uncovered territoriesLEFT JOIN + IS NULL finds rows with no match.
Org chart (recursive)A recursive CTE walks the ReportsTo tree.
Price history of Queso CabralesOrder lines keep the price charged on the day.
IS NULLThe only reliable test for a missing value.
count(*) vs count(column)Why counting after a LEFT JOIN goes wrong.
Revenue by categoryGROUP BY with a derived revenue column.
Shipper performancejulianday() differences give days to ship.
Sales by quarterstrftime() and integer division make quarters.
Priciest product per categoryA correlated subquery, run per row.
Lost customersEXISTS and NOT EXISTS together.
Category Sales for 1997A view built on a view built on a view.
+ versus ||Why T-SQL string joins return 0 in SQLite.
Ten Most Expensive ProductsMicrosoft's procedure, as ORDER BY + LIMIT.
Rank within countryrank() OVER (PARTITION BY ...).
Running total by monthsum() OVER and lag() for month-on-month.
Top two products per categoryrow_number() for a top-N per group.
Plan: indexed lookupEXPLAIN QUERY PLAN: SEARCH via an index.
Plan: a joinA join that uses a covering index.
BLOB sizestypeof() and length() on stored pictures.
What you can't do here, and why
INSERT, UPDATE, DELETE, CREATE, DROP, ATTACH, BEGIN and any PRAGMA that changes a setting are all refused, because this is a shared demonstration. On your own copy everything works: download northwind.db and run sqlite3 northwind.db. Try DELETE FROM Orders; here to see the refusal.