SQL: Analyzing Business Metrics - 9/12 Question #2


#1

Is it just me or is anyone else experiencing trouble submitting the query for 9/12 in the Advanced Aggregates?

Whenever I click 'Run', my browser experiences heavy latency and the little green indicator showing 'Connected to CodeAcademy' turns grey. I've examined my query at length to ensure there is no loop and still cannot progress in the lesson. This is becoming very aggravating and I would love to hear anything tips or suggestions to remedy this problem.

I have attempted completing the exercise on two other computers and even my iPad.


#2

Here is my query. I left this lesson alone all night (I work 3rd shift) and it still lags out.

select *,
	case name
  	when 'kale-smoothie'    then 'smoothie'
    when 'banana-smoothie'  then 'smoothie'
    when 'orange-juice'     then 'drink'
    when 'soda'             then 'drink'
    when 'blt'              then 'sandwich'
    when 'grilled-cheese'   then 'sandwich'
    when 'tikka-masala'     then 'dinner'
    when 'chicken-parm'     then 'dinner'
    else 'other'
  end as category,
  round(1.0 * sum(amount_paid) /
    (select sum(amount_paid) from order_items) * 100, 2) as pct
from order_items 
group by 1 
order by 2 desc;

#3

I have the exact same problem :confused:


#4

At first I was considering amount of users logged in working on that problem, but with how frequently I attempt completion and still get the error(s), I suspect there is a problem on CodeAcademy's end.


#5

Hello there:
This one works:

select *,
case name
when 'kale-smoothie' then 'smoothie'
when 'banana-smoothie' then 'smoothie'
when 'orange-juice' then 'drink'
when 'soda' then 'drink'
when 'blt' then 'sandwich'
when 'grilled-cheese' then 'sandwich'
when 'tikka-masala' then 'dinner'
when 'chicken-parm' then 'dinner'
else 'other'
end as category
from order_items
order by id
limit 100;


#6

After i unsuccessful tried it, i've "Get the Code", but it doesn't work:

select
case name
when 'kale-smoothie' then 'smoothie'
when 'banana-smoothie' then 'smoothie'
when 'orange-juice' then 'drink'
when 'soda' then 'drink'
when 'blt' then 'sandwich'
when 'grilled-cheese' then 'sandwich'
when 'tikka-masala' then 'dinner'
when 'chicken-parm' then 'dinner'
else 'other'
end as category, round(1.0 * sum(amount_paid) /
(select sum(amount_paid) from order_items) * 100, 2) as pct
from order_items
group by category
order by 2 desc;

Any help would be appreciated.

RML


#7

It's not like there is an infinite loop in the code that would crash the browser... is it possible that this is a bug on Codecademy's side? Has anyone else besides myself reported a bug to them?


#8

On question 2, you cannot use select *,. I don't know what causes the crash, but you must use select case name. Then continue with the code as shown.


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.