Run your first SQLite query on Mac
Find paid orders worth at least $25, with the largest first. You will move from browsing a table to asking a precise question with SQL.
1. Inspect the orders table
Choose orders in the sidebar. You should see six records, with IDs 101 through 106. Choose Structure to inspect the columns. The id column identifies each order; customer_id links it to a customer. Amounts are stored in total_cents, so 4200 means $42.00.
2. Run a read-only query
Switch to Query, paste the SQL below and choose Run. Keep the lock closed. Paste only SQL here; Terminal commands such as sqlite3 and .tables do not belong in this editor.
SELECT id, ordered_at, total_cents
FROM orders
WHERE status = 'paid' AND total_cents >= 2500
ORDER BY total_cents DESC;
3. Check your answer
You should get three rows, in this order: 105 → 6500, 101 → 4200, 103 → 2800. The query only reads records; it has not removed the other three orders.
SELECT chooses columns, FROM chooses the table, WHERE keeps matching records, and ORDER BY … DESC puts larger amounts first. The text value 'paid' uses single quotes.
4. Change one thing
Replace 2500 with 5000 and run again. Only order 105 should remain. Restore 2500, then change DESC to ASC: the same three records appear smallest first. This is a useful way to learn SQL: predict the change before running it.
If your result differs
Confirm the selected database is the practice file and that you copied the complete query. A “no such table” error usually means the wrong file is open or a name was mistyped. An empty result can be correct for different conditions. Download a fresh copy if you edited the exercise data.
Next, show customer names beside those orders. Use the grid when you want to scan records; use Query when you want to state the same question precisely and repeat it.
Updated