Bird
0
0

Consider this dbt model in the intermediate layer:

medium📝 Predict Output Q4 of 15
dbt - Project Organization
Consider this dbt model in the intermediate layer:
SELECT product_id, AVG(price) AS avg_price FROM {{ ref('stg_products') }} GROUP BY product_id

What columns will this model produce?
Aproduct_id, AVG(price)
Bproduct_id, price
Cproduct_id, avg_price
Dproduct_id only
Step-by-Step Solution
Solution:
  1. Step 1: Identify selected columns

    The query selects product_id and calculates AVG(price) as avg_price.
  2. Step 2: Understand aliasing

    The aggregate function AVG(price) is aliased as avg_price, so the output column will be named avg_price.
  3. Final Answer:

    product_id, avg_price -> Option C
  4. Quick Check:

    Check column aliases in SELECT clause [OK]
Quick Trick: Alias aggregate functions to name output columns [OK]
Common Mistakes:
MISTAKES
  • Confusing function name with output column name
  • Assuming original column names are preserved without alias
  • Ignoring GROUP BY columns in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes