Skip to content

Concept preview by SkillEra.IO, LLC. These sites have no accounts or forms; analytics and the external contact page are covered in Privacy.

SQL Query Practice

Experimental

Write one query that answers the question about a small shop's customers, products and orders. Two hidden datasets check that it follows the question, not just the sample. SQLite dialect; new to SQL? Start with SQLite's SELECT reference (opens in a new tab).

Customers in Chicago

Select and filter

List the names of customers who live in Chicago.

Tables (and the sample data)

customers

People who buy from the shop

  • id integer: Customer number
  • name text: Name
  • city text: City
  • joined text: Date they joined (YYYY-MM-DD)
Sample rows (8)
Sample customers
idnamecityjoined
1Ana P.Lisbon2023-02-14
2Ben K.Chicago2022-11-03
3Chloe M.Toronto2024-01-20
4Dev R.Chicago2021-06-30
5Ema S.Lisbon2024-05-02
6Femi O.Lagos2023-09-12
7Gus T.Osaka2022-03-08
8Hana Y.Osaka2024-07-19

products

What the shop sells

  • id integer: Product number
  • name text: Name
  • category text: Category
  • price real: Price in dollars
Sample rows (8)
Sample products
idnamecategoryprice
1Desk lampLighting34.5
2Notebook A5Stationery4.25
3Monitor armFurniture89
4Gel pens (10)Stationery7.8
5Standing matFurniture45
6USB-C hubElectronics29.99
7Webcam HDElectronics59
8Desk organiserStationery18.4

orders

One row per order

  • id integer: Order number
  • customer_id integer: Who ordered (customers.id)
  • ordered text: Order date (YYYY-MM-DD)
  • status text: placed, shipped or cancelled
Sample rows (10)
Sample orders
idcustomer_idorderedstatus
112024-09-02shipped
222024-09-05shipped
312024-09-17cancelled
432024-10-01shipped
542024-10-03placed
622024-10-11shipped
762024-10-15shipped
872024-10-22cancelled
952024-11-02placed
1012024-11-06shipped

order_items

The products in each order

  • order_id integer: Which order (orders.id)
  • product_id integer: Which product (products.id)
  • qty integer: How many
Sample rows (15)
Sample order_items
order_idproduct_idqty
111
123
261
242
331
471
425
551
612
762
741
871
922
1031
1044

One SELECT (or WITH … SELECT) query, SQLite dialect. Run tries it on the sample data below (Ctrl+Enter); Check also tests two hidden datasets.

Result

Run your query to see its rows, or Check it against every dataset.

Queries run in your browser, on SQLite compiled to WebAssembly (sql.js), in a background worker with a time limit; nothing you type leaves the page. The tables are read-only and the data is made up. The hidden datasets ship with the page, so they aren't secret: they're there to catch answers that only fit the sample, not to stop anyone looking. Checked in Chrome and Edge 120 or later; other browsers aren't verified. If the SQL engine can't start, the page says so.