FAQ: Advanced Aggregates - Meal Sums

This community-built FAQ covers the “Meal Sums” exercise from the lesson “Advanced Aggregates”.

Paths and Courses
This exercise can be found in the following Codecademy content:

SQL: Analyzing Business Metrics

FAQs on the exercise Meal Sums

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Assuming I would like to calcute the share of kale purchases to total purchases for each day - is there a way to simplify my code below? I was stuck getting a second column for the conditional sum for the kale smoothies purchased - is there a way to display these 3 (or 4 if we want the share too) colums: date, sum total, sum kale smoothie without having to create a temporary table? Thanks in advance!!

WITH total AS(
SELECT date (ordered_at) AS ‘date_total’, SUM(amount_paid) AS ‘paid_total’
FROM orders
LEFT JOIN order_items
ON orders.id =order_items.order_id
kale AS (
SElECT date(ordered_at) AS ‘date_kale’, SUM(amount_paid) AS ‘paid_kale’
FROM orders
LEFT JOIN order_items
ON orders.id =order_items.order_id
WHERE name = ‘kale-smoothie’
SELECT date_total, paid_total, paid_kale, paid_kale/paid_total AS ‘ratio’
FROM total
ON total.date_total = kale.date_kale;