view: dt_per_play_rate_by_country { sql_table_name: INTELLIGENCE.DBT_PROD.DT_PER_PLAY_RATE_BY_COUNTRY ;; # derived_table: { # sql: # WITH accounting_months AS ( # SELECT DISTINCT accountingperiodid # FROM royalty_accounting.prod.workstation_fact_sales_unified_dbt # ORDER BY 1 DESC # LIMIT 3 # ), # group_by_country AS ( # SELECT # fs.countryid, # SUM(fs.sales) AS units, # SUM(fs.gross) AS gross # FROM accounting_months am # INNER JOIN royalty_accounting.prod.workstation_fact_sales_unified_dbt fs ON am.accountingperiodid = fs.accountingperiodid # WHERE storeid IN (1,286) AND transactiontypeid IN (1,10) # GROUP BY 1 # ) # SELECT # dc.countryname AS country, # (gross / units * 1000) AS per_play_rate # FROM group_by_country gbc # INNER JOIN facts.prod.dim_country dc ON gbc.countryid = dc.countryid ;; # } dimension: country { type: string sql: ${TABLE}.country ;; primary_key: yes } dimension: per_play_rate { type: number sql: ${TABLE}.per_play_rate ;; } }