Skip to content

Commit c161272

Browse files
authored
Create calculate-product-final-price.sql
1 parent a5a97e0 commit c161272

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Time: O(nlogn)
2+
# Space: O(n)
3+
4+
SELECT p.product_id,
5+
p.price * IFNULL(1 - d.discount / 100, 1) AS final_price,
6+
p.category
7+
FROM products p
8+
LEFT JOIN discounts d ON p.category = d.category
9+
ORDER BY 1;

0 commit comments

Comments
 (0)