SQL Quest › SQL Interview Questions › Conditional Logic

LLC vs Individual Buyers

MediumFreeQuerying BasicsConditional LogicAggregation & GroupingString Functions

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". Free accounts get 10 free challenge solves, and this can be one of them.

Schema

sales

document_idrecord_typedoc_typerecorded_boroughdocument_datedocument_amtrecorded_datetime
2025081800333001ADEED12025-08-1410800000002025-08-18
2024012300948001ADEED12024-01-229630000002024-01-24
2025081800439001ADEED12025-08-148100000002025-08-20

sales_parties

document_idparty_typeparty_rolename
20260302001740051SELLERRIVER'S EDGE
20260302004230051SELLERSTANLEY AVENUE PRESERVATION HDFC
20260302004230052BUYERNEW YORK CITY HOUSING DEVELOPMENT CORPORATION

Expected output: Two rows comparing the two segments

Hint

CASE WHEN p.name LIKE '%LLC%' OR p.name LIKE '%INC%' OR p.name LIKE '%CORP%' OR p.name LIKE '%TRUST%' THEN 'LLC/Corp' ELSE 'Individual' END.

Concepts

SELECT CASE GROUP BY Aggregation String Functions

Practise the topic: SQL practice questions · CASE WHEN practice · GROUP BY exercises · String function practice

Read the concept: SQL CASE WHEN tutorial

Related questions

Bonus Tier with Cross-ConditionsMedium · FreePromotion Eligibility MatrixMedium · FreeTrust and Savings BanksMedium · FreeTicket-Size Mix by CategoryMedium · FreeDays to KYC Verification by CountryMedium · FreeReferred vs Organic: First-Month SpendMedium · Free

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