# Influenced-pipeline query

> Template · Section 15.3 from *The GTM Engineering Handbook* by Jared Waxman (GTM Engineer School).  
> Web version: https://gtm-engineer-school.com/resources/gtme-handbook/templates/influenced-pipeline-sql/  
> Last updated: 2026-11-28  
> © 2026 Jared Waxman. All rights reserved. Short quotations with attribution and a link are welcome.

## Influenced-pipeline query

*From Section 15.3.*

A simple SQL sketch that attributes opportunities to plays that touched the account in the 90 days before the opportunity was created.

Table and column names are examples. The cutoff date `2026-07-01` is example data; replace it with the start of your reporting window. This is play-level influence, not a claim that the play caused the opportunity (Chapter 15).

```sql
-- Influenced pipeline by play: any play that touched the account
-- in the 90 days before the opportunity was created.
-- The cutoff date below is example data.
with opp as (
  select opp_id, account_id, created_at, amount
  from fct_opportunities
  where created_at >= date '2026-07-01'
),
touches as (
  select distinct o.opp_id, o.amount, a.play_id
  from opp o
  join fct_activities a
    on a.account_id = o.account_id
   and a.play_id is not null
   and a.occurred_at between o.created_at - interval '90 days' and o.created_at
)
select
  play_id,
  count(*)    as opps_influenced,
  sum(amount) as pipeline_influenced
from touches
group by play_id
order by pipeline_influenced desc;
```

---

All concepts: [concepts.md](https://gtm-engineer-school.com/resources/gtme-handbook/concepts.md) · Practitioner questions: [questions.md](https://gtm-engineer-school.com/resources/gtme-handbook/questions.md) · All chapters: [llms.txt](https://gtm-engineer-school.com/resources/gtme-handbook/llms.txt)
