Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Customer Spending Analysis | CASE WHEN for Aggregates and Reporting
Mastering CASE WHEN in SQL

bookChallenge: Customer Spending Analysis

Завдання

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.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 2
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

bookChallenge: Customer Spending Analysis

Свайпніть щоб показати меню

Завдання

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.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 2
single

single

some-alt