← All SQL interview questions

Find every store-product listing gap

HardJoins — Cross JoinTargetAmazonMeesho

A category manager wants a full coverage matrix: every store should ideally list every active product. The team needs the gaps.

Build the complete store × product grid and return store_code, product_code and product_name for every combination that is missing from store_listings. Only include products where is_active is true.

Sample data

Table: stores

4 row(s)

store_codeTEXTstore_cityTEXT
ST-01Pune
ST-02Hyderabad
ST-03Kolkata
ST-04Jaipur

Table: products

5 row(s)

product_codeTEXTproduct_nameTEXTis_activeBOOLEAN
PR-ACold Brew Concentratetrue
PR-BMillet Cereal Packtrue
PR-CBamboo Toothbrushtrue
PR-DDiscontinued Gift Boxfalse
PR-ESteel Water Bottletrue

Table: store_listings

14 row(s) · showing first 8

store_codeTEXTproduct_codeTEXTshelf_unitsINT
ST-01PR-A12
ST-01PR-B8
ST-01PR-C5
ST-01PR-E9
ST-02PR-A15
ST-02PR-C4
ST-03PR-B11
ST-03PR-D2

Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.

Explore the program