Used a different approach, got the same answer. This answer was not accepted. Please provide your feedback

Screen Link:

My Code:

    india AS
        SELECT * FROM customer
        WHERE country = "India"
    total_purchase AS
            SELECT c.first_name, c.last_name, c.customer_id, 
            SUM( as purchase
            FROM customer c
            INNER JOIN invoice i
            ON c.customer_id= i.customer_id
            GROUP BY i.customer_id            
SELECT p.first_name || ' '||p.last_name AS customer_name,
p.purchase as total_purchase
FROM india i
INNER JOIN total_purchase p
on i.customer_id= p.customer_id

What I expected to happen: Since results are the same, this should have worked

What actually happened: Answer did not get accepted

The value for result doesn't look right.

My question is, does my answer work? Agreed, there was no need for first and last name in second subquery and the inner join wasn’t needed in it either.


Hello @nandy.arijit, Welcome back to the community. Your code looks amazing.

Here is what is causing the error, the final column should be total_purchases

  • total_purchases - The total amount spent on purchases by that customer.

If you correct that everything will be fine.


Thanks Victor! Good callout, my mistake. Appreciate your quick response!

1 Like