text: 
  
  
  {{
    config(
      materialized='table'
    )
  }}
  
  with cte1 as (
  select product_id, count(distinct session_id) as session_views
  from {{ ref('int_page_views') }}
  group by product_id
  ),
  cte2 as (
  select product_id, count(distinct session_id) as session_purchases
  from {{ ref('int_product_purchases') }}
  group by product_id)
  
  select cte1.product_id, session_views, session_purchases, (cast(session_purchases as float)/session_views)*100 as conversion_rate_perc
  from cte1
  left join cte2
  on cte1.product_id = cte2.product_id