Challenge: Customer Spending Analysis
Opgave
Swipe to start coding
Write a query that shows, for each customer, the total 'purchase' and 'refund' amounts as separate columns.
- Select
customer_idfrom thetransactionstable. - Calculate the sum of
amountfor transactions wheretransaction_typeis 'purchase' and display it astotal_purchase. - Calculate the sum of
amountfor transactions wheretransaction_typeis 'refund' and display it astotal_refund. - Group the results by
customer_id. - Display one row per customer.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 4. Kapitel 2
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Fantastisk!
Completion rate forbedret til 4.17
Challenge: Customer Spending Analysis
Stryg for at vise menuen
Opgave
Swipe to start coding
Write a query that shows, for each customer, the total 'purchase' and 'refund' amounts as separate columns.
- Select
customer_idfrom thetransactionstable. - Calculate the sum of
amountfor transactions wheretransaction_typeis 'purchase' and display it astotal_purchase. - Calculate the sum of
amountfor transactions wheretransaction_typeis 'refund' and display it astotal_refund. - Group the results by
customer_id. - Display one row per customer.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 4. Kapitel 2
single