← All SQL interview questions

Match every order to its customer

MediumJoins — Inner JoinPayPalRazorpay

The finance team reconciles a payment export against the customer master. Orders whose customer record was purged should not appear.

Join orders_ledger to customer_master and return order_id, customer_name, segment and amount for orders where the customer still exists.

Sample data

Table: customer_master

10 row(s) · showing first 8

customer_idINTcustomer_nameTEXTsegmentTEXT
11Ira BansalRetail
12Devansh RaoRetail
13Nikhil SarinSMB
14Mahima SethiEnterprise
15Yusuf AliSMB
16Prerna IyerEnterprise
17Sagar NaikRetail
18Rhea KapoorSMB

Table: orders_ledger

14 row(s) · showing first 8

order_idINTcustomer_idINTorder_dateDATEamountNUMERIC(10,2)
5001112026-01-052400.00
5002122026-01-085100.50
5003992026-01-111800.00
5004132026-01-1512200.00
5005142026-01-197650.00
5006152026-01-22980.00
5007982026-01-254300.00
5008162026-02-0118900.00

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

Explore the program