Two Lists, Sorted Apart
Problem
An auction tool keeps a table `auction_book` with columns `(low_bid, high_bid)`. There is no primary key and the table may contain duplicate values.
Produce a single two-column result that sorts each column independently and lines them up row by row:
1. `low_bid` sorted ascending.
2. `high_bid` sorted descending.
3. The two sorted sequences placed side by side (the smallest `low_bid` next to the largest `high_bid`, and so on).
The two columns are sorted separately; values that shared a row in the source are not kept together.
Tables
Example rows — the live problem includes the full dataset.
| low_bid | high_bid |
|---|---|
| 40 | 20 |
| 20 | 30 |
| 30 | 10 |
Expected output
Your answer should return 4 rows with the columns low_bid, high_bid.
Starter code (SQL)
SELECT *
FROM auction_book;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock