Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Customer Spending Analysis | CASE WHEN for Aggregates and Reporting
Practice
Projects
Quizzes & Challenges
Quiz
Challenges
/
Mastering CASE WHEN in SQL

bookChallenge: Customer Spending Analysis

Compito

Swipe to start coding

Write a query that shows, for each customer, the total 'purchase' and 'refund' amounts as separate columns.

  • Select customer_id from the transactions table.
  • Calculate the sum of amount for transactions where transaction_type is 'purchase' and display it as total_purchase.
  • Calculate the sum of amount for transactions where transaction_type is 'refund' and display it as total_refund.
  • Group the results by customer_id.
  • Display one row per customer.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 2
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

bookChallenge: Customer Spending Analysis

Scorri per mostrare il menu

Compito

Swipe to start coding

Write a query that shows, for each customer, the total 'purchase' and 'refund' amounts as separate columns.

  • Select customer_id from the transactions table.
  • Calculate the sum of amount for transactions where transaction_type is 'purchase' and display it as total_purchase.
  • Calculate the sum of amount for transactions where transaction_type is 'refund' and display it as total_refund.
  • Group the results by customer_id.
  • Display one row per customer.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 2
single

single

some-alt