Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Monthly VIP Customer Report | CASE WHEN for Aggregates and Reporting
Mastering CASE WHEN in SQL

bookChallenge: Monthly VIP Customer Report

Oppgave

Swipe to start coding

Write a query to generate a monthly report of VIP customers based on their transaction history. A customer is considered "VIP" for a given month if they have a total transaction amount of at least 500 and have made at least 2 transactions in that month.

  • Group transactions by month and customer.
  • Calculate the total transaction amount for each customer per month.
  • Count the number of transactions for each customer per month.
  • Use CASE WHEN to label customers as 'VIP' if they meet both criteria: total amount >= 500 and transaction count >= 2.
  • Only include customers who qualify as VIP in the results.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 6
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Monthly VIP Customer Report

Sveip for å vise menyen

Oppgave

Swipe to start coding

Write a query to generate a monthly report of VIP customers based on their transaction history. A customer is considered "VIP" for a given month if they have a total transaction amount of at least 500 and have made at least 2 transactions in that month.

  • Group transactions by month and customer.
  • Calculate the total transaction amount for each customer per month.
  • Count the number of transactions for each customer per month.
  • Use CASE WHEN to label customers as 'VIP' if they meet both criteria: total amount >= 500 and transaction count >= 2.
  • Only include customers who qualify as VIP in the results.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 6
single

single

some-alt