Skip to content

Commit

Permalink
Create pizza-toppings-cost-analysis.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 authored Mar 4, 2024
1 parent 6c68d7f commit 54678e0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions MySQL/pizza-toppings-cost-analysis.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Time: O(n^3 * logn)
# Space: O(n^3)

SELECT CONCAT(t1.topping_name, ",", t2.topping_name, ",", t3.topping_name) AS pizza,
ROUND(t1.cost + t2.cost + t3.cost, 2) AS total_cost
FROM Toppings t1
INNER JOIN Toppings t2
ON t1.topping_name < t2.topping_name
INNER JOIN Toppings t3
ON t2.topping_name < t3.topping_name
ORDER BY 2 DESC, 1;

0 comments on commit 54678e0

Please sign in to comment.