Forum

Posted by Bowen, Dec. 10, 2022, 7:19 p.m.

Why this solution is not accepted? (quetsion # 140)

This query can yield the same results with the 'official' solution, but it's not accepted by the system.

Can someone tell me why?

with daily_rev as 
(select 
date(created_at) as date,
restaurant_id,
sum(total_amt) as daily_revenue

from food_order
where restaurant_id = 100011
group by 1,2
)
select 
a.date,
coalesce(b.restaurant_id,100011) as restaurant_id,
coalesce(b.daily_revenue,0) as daily_revenue

from dates a left join daily_rev b 
on a.date = b.date
where a.date >= '2021-08-01'
and a.date < '2021-09-01'

Answers

Hey Bowen,

Thanks for your question, I'd consider your query to be a correct one, the issue was there were a few records that have a few decimals points off, I wouldn't worry about it. 

If you'd like us to mark your solution as a pass, let us know. 

This happens to a few more questions as well: see https://sqlpad.io/forum/question/228/weird-sensitivity-to-decimal-points/

" Unfortunately, our OJ uses assert to check your results against our 'official' solution, that's why it has to match 100% to pass. 

It's not easy to add a 'tolerance' level to the OJ, considering the diversity of the questions, some return strings, some integers, and some are numerics.

And even for numeric types, there are different interpretations regarding the underlying implementation, e.g., Python vs. Postgres vs. MySQL.

If you have suggestions (and how we can technically implement them), happy to hear them and keep improving the product.

"

--Leon

SQLPad user avatar

Leon (949)

Dec. 15, 2022, 9:53 a.m.