Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions dbt/models/marts/finance/finance_excellent_rating_revenue.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- Finance model: product-level revenue breakdown for the Excellent rating cohort
-- Excellent tier = avg_rating >= 4.5 as defined in dim_products
-- Use this model to analyse which top-rated products drive the most revenue

with excellent_cohort as (

select
product_id,
product_name,
product_category,
avg_rating,
rating_tier,
review_count,
positive_reviews,
negative_reviews,
total_units_sold,
unit_price,
unit_margin,
margin_pct,
product_total_revenue,
product_gross_profit

from {{ ref('dim_products') }}

where rating_tier = 'Excellent'

)

select
product_id,
product_name,
product_category,
avg_rating,
rating_tier,
review_count,
positive_reviews,
negative_reviews,
total_units_sold,
unit_price,
unit_margin,
margin_pct,
product_total_revenue,
product_gross_profit

from excellent_cohort

order by product_total_revenue desc