← All SQL interview questions

Order lines with product and category names

MediumJoins — Inner JoinAmazonFlipkart

An operations analyst needs a readable list of the bigger order lines, with the product and category names instead of IDs.

Join order_items, products and categories. Return order_id, product_name, category_name, quantity and line_total (quantity * unit_price) for lines whose line_total is 2000 or more. Order by line_total descending, then item_id.

Sample data

Table: categories

4 row(s)

category_idINTcategory_nameTEXT
1Electronics
2Home
3Fashion
4Grocery

Table: products

8 row(s)

product_idINTproduct_nameTEXTcategory_idINT
101Wireless Earbuds1
102Phone Case1
103Air Fryer2
104Bedsheet Set2
105Running Shoes3
106Basmati Rice 5kg4
107Desk Lamp2
108Tote Bag3

Table: order_items

14 row(s) · showing first 8

item_idINTorder_idINTproduct_idINTquantityINTunit_priceNUMERIC(10,2)
1900110112499.00
290011022299.00
3900210315999.00
490021062640.00
5900310421199.00
690031071899.00
7900410513299.00
890041083449.00

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

Explore the program