Seção 4. Capítulo 6
single
Challenge: Monthly VIP Customer Report
Deslize para mostrar o menu
Tarefa
Deslize para começar a programar
Write a SQL query to generate a monthly VIP customer report based on transaction history.
- Use the
transactionstable which containstransaction_date,customer_id, andamountcolumns. - Select
month(formatted as'YYYY-MM'usingTO_CHAR),customer_id,total_amount,transaction_count, andvip_status. - Group by
monthandcustomer_id. - Calculate
total_amountasSUM(amount)andtransaction_countasCOUNT(*)per customer per month. - Use
CASE WHENto setvip_status = 'VIP'iftotal_amount >= 500ANDtransaction_count >= 2, otherwiseNULL. - Use
HAVINGto return only rows where both VIP conditions are met.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 4. Capítulo 6
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo