-- This Transform represents an individual opportunity, which is a sale or a pending deal in Salesforce -- This Transform pulls out some of the most important fields from the "opportunity" table in Salesforce.
with opportunity as (
id as opportunity_id,
name as opportunity_name,
), opportunity_calculated as (
created_date >= date_trunc('month', current_timestamp()) as is_created_this_month,
created_date >= date_trunc('quarter',current_timestamp()) as is_created_this_quarter,
datediff('day', created_date, current_timestamp()) as days_since_created,
datediff('day', created_date, close_date) as days_to_close,
date_trunc('month', close_date) = date_trunc('month', current_timestamp()) as is_closed_this_month,
date_trunc('quarter', close_date) = date_trunc('quarter', current_timestamp()) as is_closed_this_quarter
where not coalesce(is_deleted, false)
Learn more about the WITH clause and common table expressions (CTEs) through Snowflake (our data warehouse partner) or Mode (a business intelligence tool partner).