← All SQL interview questions
Null-safe order totals with discounts and shipping
MediumNULL / NOT NULL HandlingZomatoMeesho
The checkout table leaves discount and shipping_fee as NULL when they do not apply, which silently breaks arithmetic totals.
From checkout_lines, return line_id, gross_amount, discount_applied (0 when missing), shipping_charged (0 when missing) and net_payable = gross − discount + shipping, treating missing values as 0. Also return coupon_label, which should read No coupon when coupon_code is NULL.
Sample data
More NULL / NOT NULL Handling questions
Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.
Explore the program