SQL Quest › SQL Interview Questions › Conditional Logic
LLC vs Individual Buyers
Categorize buyers as 'LLC/Corp' if their name contains 'LLC', 'INC', 'CORP', or 'TRUST', else 'Individual'. Show buyer_type, buyer_count, total_volume. Order by total_volume descending.
Solve it in the browser editor →
Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".
Schema
sales
| document_id | record_type | doc_type | recorded_borough | document_date | document_amt | recorded_datetime |
|---|---|---|---|---|---|---|
| 2025081800333001 | A | DEED | 1 | 2025-08-14 | 1080000000 | 2025-08-18 |
| 2024012300948001 | A | DEED | 1 | 2024-01-22 | 963000000 | 2024-01-24 |
| 2025081800439001 | A | DEED | 1 | 2025-08-14 | 810000000 | 2025-08-20 |
sales_parties
| document_id | party_type | party_role | name |
|---|---|---|---|
| 2026030200174005 | 1 | SELLER | RIVER'S EDGE |
| 2026030200423005 | 1 | SELLER | STANLEY AVENUE PRESERVATION HDFC |
| 2026030200423005 | 2 | BUYER | NEW YORK CITY HOUSING DEVELOPMENT CORPORATION |
Expected output: Two rows comparing the two segments
Hint
Concepts
SELECT CASE GROUP BY Aggregation String Functions
Practise the topic: SQL practice questions · CASE WHEN practice · GROUP BY exercises · String function practice
Related questions
Where would this cost you points in an interview?
Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.
Take the readiness test