Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Customer Spending Analysis | CASE WHEN for Aggregates and Reporting
Mastering CASE WHEN in SQL

bookChallenge: Customer Spending Analysis

Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 2
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Customer Spending Analysis

Pyyhkäise näyttääksesi valikon

Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 2
single

single

some-alt