Reference queries against a typical revenue warehouse schema (Snowflake / BigQuery / Postgres). Pasted into a notebook or run via duckdb against a flat CSV export — they're written to be portable.
Schema assumed:
| Source | Tables |
|---|---|
| Salesforce | accounts, opportunities, opportunity_history, contacts, tasks |
| HubSpot | hubspot_contacts, hubspot_engagements |
| Product analytics | product_events, product_usage_daily |
| Support | zendesk_tickets, zendesk_csat |
| Marketing | marketo_activities or pardot_visitor_activities, ad_clicks |
Each query has a -- USED BY: line up top pointing to the automation that calls it.
| Query | Purpose |
|---|---|
| account_health.sql | Composite health score per account |
| conversion_funnel.sql | Stage-to-stage conversion rates by segment |
| pipeline_velocity.sql | Days-in-stage + deal slip detection |
| renewal_risk_features.sql | Feature set for the renewal-risk model |
| abm_attribution.sql | Multi-touch attribution for ABM campaigns |
| event_lead_attribution.sql | Event-sourced leads → opportunity outcome |