Complete the code to create a simple dbt model that selects all columns from the source table.
select * from [1]
The source table is the raw data we select from in a dbt model. Using select * from source_table creates a basic model.
Complete the code to reference another dbt model named 'customers' inside a model.
select * from [1]
In dbt, ref('model_name') is used to reference another model. This ensures dependencies are tracked.
Fix the error in the dbt model code to correctly create a model that filters customers with more than 100 orders.
select * from [1] where order_count > 100
The correct way to reference a model in dbt is using ref('model_name') with quotes around the model name.
Fill both blanks to create a dbt model that calculates total sales per customer and orders results by total sales descending.
select customer_id, sum(sales) as total_sales from [1] group by customer_id order by [2] desc
We reference the 'orders' model using ref('orders'). Then we order by the alias total_sales descending.
Fill all three blanks to create a dbt model that joins customers and orders, selecting customer name and total order amount.
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]
We reference the customers and orders models with ref(). Grouping is done by the customer name alias c.customer_name.