BLACK FRIDAY EXTRA SAVINGS EVENT - EXTENDED
START FREE

Https://app.dataquest.io/c/46/m/179/joining-data-in-sql/8/challenge-complex-query-with-joins-and-subqueries

https://app.dataquest.io/c/46/m/179/joining-data-in-sql/8/challenge-complex-query-with-joins-and-subqueries

I use below sql query and could get the correct result, while the error message pops out.

SELECT f.name country,
       s.urban_pop urban_pop,
       f.population total_pop,
       ROUND(CAST(s.urban_pop AS FLOAT) / f.population, 6) urban_pct 
    FROM facts f
    INNER JOIN (SELECT facts_id,
                       SUM(population) urban_pop
                       FROM cities
                       GROUP BY facts_id
                ) s ON s.facts_id = f.id
    WHERE urban_pct > 0.5
    ORDER BY urban_pct

May I know what’s wrong?

Hi @xuyangchen8635. It looks like the only reason your code is not being accepted by the system is because of a rounding error. The autograder is expecting full precision but your code is rounding off values to 6 decimal places. If you remove the rounding, your answer will be accepted as the correct solution.