Bird
0
0

How can you combine advanced patterns in dbt to handle a scenario where you need to calculate customer lifetime value (LTV) and segment customers by LTV tiers?

hard🚀 Application Q9 of 15
dbt - Advanced Patterns
How can you combine advanced patterns in dbt to handle a scenario where you need to calculate customer lifetime value (LTV) and segment customers by LTV tiers?
ACalculate LTV and tiers in separate unrelated models without joining
BUse nested CTEs to calculate LTV, then apply CASE statements to assign tiers
CUse only one CTE with all logic combined in a single SELECT
DManually assign tiers outside dbt after exporting data
Step-by-Step Solution
Solution:
  1. Step 1: Recognize the need for multi-step calculations

    LTV calculation and tier assignment require sequential logic.
  2. Step 2: Apply nested CTEs and CASE statements

    Nested CTEs allow stepwise calculation; CASE assigns tiers based on LTV.
  3. Final Answer:

    Use nested CTEs to calculate LTV, then apply CASE statements to assign tiers -> Option B
  4. Quick Check:

    Nested CTEs + CASE = effective for LTV tiers [OK]
Quick Trick: Combine nested CTEs with CASE for tier segmentation [OK]
Common Mistakes:
MISTAKES
  • Separating calculations without joining
  • Putting all logic in one query
  • Doing tier assignment outside dbt

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes