Bird
0
0

Given the following dbt model code in the intermediate layer:

medium📝 Predict Output Q13 of 15
dbt - Project Organization
Given the following dbt model code in the intermediate layer:
SELECT
  customer_id,
  COUNT(order_id) AS total_orders
FROM {{ ref('stg_orders') }}
GROUP BY customer_id

What will be the output columns of this model?
Acustomer_id, total_orders
Border_id, total_orders
Ccustomer_id, order_id
Dcustomer_id only
Step-by-Step Solution
Solution:
  1. Step 1: Analyze SELECT statement

    The query selects customer_id and counts order_id as total_orders.
  2. Step 2: Understand GROUP BY effect

    Grouping by customer_id means output will have one row per customer with total orders counted.
  3. Final Answer:

    customer_id, total_orders -> Option A
  4. Quick Check:

    Output columns = customer_id and total_orders [OK]
Quick Trick: GROUP BY columns + aggregated columns appear in output [OK]
Common Mistakes:
MISTAKES
  • Expecting order_id as output column
  • Missing aggregated column in output
  • Confusing GROUP BY with WHERE clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes