Chapter 5 · JOINs
22. Order Line Items with Product Details
Medium20 XPE-Commerce
Build a detailed invoice view. For each order_item, show the order_id, product name, quantity, unit_price, discount, and the line total (quantity * unit_price - discount, where discount is the dollar amount taken off the line). Sort by order_id then product name.
Tables
- PKidINT
- nameTEXT
- FKcategory_id→ categories.idINT
- priceREAL
- costREAL
- stock_quantityINT
- created_atTIMESTAMP
- PKidINT
- FKorder_id→ orders.idINT
- FKproduct_id→ products.idINT
- quantityINT
- unit_priceREAL
- discountREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.