There is a table like this, how can I get customer_id
, amount_spent
, top_item
out of it?
amount_spent
the amount spent on all items by this customer
top_item
, which displays the name of the item for which the customer has spent the most money
I have tried the following query, however I cannot output the top_1 item with it
select customer_id, sum(item_number * item_price) as amount_spent_1m
from temp
group by customer_id