SQL QuestSQL 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".

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

Related questions

Movie Rating Tier BreakdownMedium · FreeGenre Financial ReportMedium · FreeDepartment Compensation ReportMedium · FreePivot: Order Status by CountryMedium · FreeGenre Box Office ReportMedium · FreeFare Imputation AnalysisMedium · 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