Turning Learners Into Developers
Codekilla
CODEKILLA
Medium
SQL-J04sql

Orders With Product Details

Problem

Given `orders(id, product_id, qty)` and `products(id, name, price)`, return each order id with `product_name` and `total = qty * price`, sorted by total desc.

Input
Two tables
Output
order_id, product_name, total
Constraints
1 ≤ rows ≤ 10^6
Sample input
orders: (1,10,2),(2,11,1)
products: (10,'Pen',5),(11,'Mug',12)
Sample output
1 | Pen | 10
2 | Mug | 12 → desc → 2,1
Explanation
Compute derived column qty*price after the join.
joinsinner-joincomputed-column@Stripe
Visible test cases
in: see prompt
out: ordered
Your solution — run it, use AI if stuck
sql