Second-highest price
beginner Subqueries Challenge 3 of 13
Find the second-highest product price in the catalogue.
Requirements
- Return one column,
second_highest: the highest price that is lower than the maximum price. - Duplicate prices count once. If two products share the top price, the answer is the next price down.
- If there is no second price, return a single row containing NULL.
Expected output
second_highest 249
Checks (3)
- ○Sample data
- ○A new most expensive product
- ○Every product has the same price
Each check builds a fresh database and compares your result with the reference solution's: same number of columns in the same order (names are not checked), and the same rows in any order.
query.sqlExecutes on SQLite in your browser
Ctrl/⌘ + Enter to check query · your code is saved in this browser
Results
Use Run query to see your rows, then Check query to grade it.
Schema · Acme Store
SQLiteLoading the database…
“null” marks columns that allow NULL. Foreign keys are not enforced, as in many real test databases.