Reorder rates 11/12 what's wrong?


#1

Hi
my answer to ''The numerator should count the distinct order_ids. The denominator should count the distinct values of the orders table's delivered_to field (orders.delivered_to)." is:

select name, round(1.0 * count(distinct order_id) /
count(distinct delivered_to), 2) as reorder_rate
from order_items
join orders on
orders.id = order_items.order_id
group by 1
order by 2 desc

anyone could shed some light for me, please?


#2

Hi,

i have tried below one, its working fine. I think we have to try to build similar queries in order as mentioned in the left side contents.

select name, round(1.0 * count(distinct order_id) /
count(distinct orders.delivered_to), 2) as reorder_rate
from order_items
join orders on
orders.id = order_items.order_id
group by 1
order by 2 desc;

Your logic is good, Can you try this?


#3

You're right. Looks like what was missing was a ....semicolon at the end:((
Thank you!!


#4

Hello - I copy and pasted this exact code and the exercise still doesn't show as complete....is this now a bug?


#5

A space before "from" you missed out.
Let the force be with you.


#6

Not only the semicolon at the end but also

the second line :count(distinct orders.delivered_to), 2) as reorder_rate. (correct one)

Your code:
count(distinct delivered_to), 2) as reorder_rate


#7

I have mine submitted as:

select name, round(1.0 * count(distinct order_id) /
count(distinct orders.delivered_to), 2) as reorder_rate
from order_items
join orders on
orders.id = order_items.order.id
group by 1
order by 2 desc;

The error I am getting says
"Error: near line 1: near "order": syntax error"

What am I missing?


#8

I have not been looking at the course for long but at first glance sthg might be wrong when specyfying join condition:
join orders on
orders.id = order_items.order.id

How about
join orders on
orders.id = order_items.order_id ?

I


#10

This is where I am, and I'm getting the same error. Did you figure out the problem?


#11

select name, round(1.0 * count(distinct order_id) / count(distinct orders.delivered_to),2) as reorder_rate from order_items join orders on orders.id = order_items.id group by 1 order by 2 desc;

Unable to move past this the '11.Reorder rate' section though the logic seems right. Any idea what's wrong?


#12

join orders on orders.id = order_items.order_id instead of join orders on orders.id = order_items.id ?


#13

Thanks damian_zb ! Figured it right after I posted here.


#14

I still can't get through the question


#16

I am putting in this

select name, round(1.0 * count(distinct order_items.order_id) /
count(distinct orders.delivered_to), 2) as reorder_rate
from order_items
join orders on
orders.id = order_items.order_id
group by 1
order by 2 desc;

and still can't pass. Something is off with the platform


#18

This topic is solved.