0
0
dbtdata~10 mins

Why models are the core of dbt - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a simple dbt model that selects all columns from the source table.

dbt
select * from [1]
Drag options to blanks, or click blank then click option'
Aref('my_model')
Bdbt_model
Csource_table
Dstaging_table
Attempts:
3 left
💡 Hint
Common Mistakes
Using ref() inside the select statement incorrectly.
Trying to select from a model name instead of a source table.
2fill in blank
medium

Complete the code to reference another dbt model named 'customers' inside a model.

dbt
select * from [1]
Drag options to blanks, or click blank then click option'
Asource('raw', 'customers')
Bref('customers')
Cdbt.customers
Dcustomers_table
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() to reference a model.
Trying to use the model name directly without ref().
3fill in blank
hard

Fix the error in the dbt model code to correctly create a model that filters customers with more than 100 orders.

dbt
select * from [1] where order_count > 100
Drag options to blanks, or click blank then click option'
Aref(customers)
Bsource('raw', 'customers')
Ccustomers
Dref('customers')
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes inside ref().
Using the model name directly without ref().
4fill in blank
hard

Fill both blanks to create a dbt model that calculates total sales per customer and orders results by total sales descending.

dbt
select customer_id, sum(sales) as total_sales from [1] group by customer_id order by [2] desc
Drag options to blanks, or click blank then click option'
Aref('orders')
Btotal_sales
Ccustomer_id
Dsource('raw', 'orders')
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by a column not selected or aliased.
Using source() instead of ref() for models.
5fill in blank
hard

Fill all three blanks to create a dbt model that joins customers and orders, selecting customer name and total order amount.

dbt
select c.customer_name, sum(o.amount) as total_amount from [1] c join [2] o on c.customer_id = o.customer_id group by [3]
Drag options to blanks, or click blank then click option'
Aref('customers')
Bref('orders')
Cc.customer_name
Do.customer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by a column not in select.
Using table names directly without ref().