DQ doesn't accept my solution

Hi !
I’m trying to figure out the Challenge : Each Country’s Best Costumer https://app.dataquest.io/m/190/building-and-organizing-complex-queries/8/challenge-each-countrys-best-customer
I found a solution that seems to return an output same as that proposed by DQ , but DQ doesn’t accept my solution , I don’t understand why , maybe the cause is the fact that in some cases some results are truncated (e.g. 39.6 instead of 39.60) , despite the fact i used the round() function. I tried to use the printf() function but it doesn’t solve the issue.
My code is :

WITH list_country AS
        c.first_name || " " || c.last_name customer_name,
        ROUND(SUM(i.total),2) total_purchased
    FROM customer c
    LEFT JOIN invoice i ON i.customer_id=c.customer_id
    GROUP BY 1,2
    ORDER BY 1
SELECT country,customer_name,MAX(total_purchased) total_purchased FROM list_country 

Any advice ?

The round function should not be the problem because from the DQ challenge explanation : " however, when running your query, don’t worry about rounding the total_purchased column".
EDIT : Ok , I just solve it. I removed the round function from the sum and DQ took my answer as correct :slight_smile:

1 Like