Bird
0
0

Given this dbt model SQL snippet, what will be the output columns?

medium📝 Predict Output Q13 of 15
dbt - Governance and Collaboration
Given this dbt model SQL snippet, what will be the output columns?
SELECT user_id, COUNT(*) AS order_count
FROM {{ ref('orders') }}
GROUP BY user_id
AAn error because GROUP BY is missing
BOnly user_id column without counts
CAll columns from orders table without aggregation
Duser_id and order_count columns with counts per user
Step-by-Step Solution
Solution:
  1. Step 1: Analyze SELECT and GROUP BY

    The query selects user_id and counts rows grouped by user_id, so output has user_id and order_count.
  2. Step 2: Confirm aggregation correctness

    GROUP BY user_id matches the aggregation COUNT(*), so query runs correctly and outputs two columns.
  3. Final Answer:

    user_id and order_count columns with counts per user -> Option D
  4. Quick Check:

    GROUP BY user_id + COUNT(*) = user_id, order_count [OK]
Quick Trick: GROUP BY columns appear with aggregated counts [OK]
Common Mistakes:
MISTAKES
  • Thinking all orders columns appear
  • Missing GROUP BY causes error
  • Ignoring COUNT(*) aggregation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes