-- Who runs the clinical trials: academia, not pharma, 2026
-- Fonteum reproducible query — https://fonteum.com/research/clinical-trial-sponsor-concentration-2026
-- Data as of: 2026-06-14  ·  methodology: clinicaltrials/v1
-- Source datasets: ClinicalTrials.gov
-- Run against the frozen federal snapshot to reproduce the published figures.
-- License: U.S. Government Works (federal sources; 17 U.S.C. §105).

-- WHO RUNS the clinical-trials registry — the composition and concentration of
-- the sponsors behind every study on ClinicalTrials.gov. Fully reproducible.
--
-- Question: of the studies registered on ClinicalTrials.gov, who sponsors them?
-- What share is run by industry vs academic/hospital vs government sponsors,
-- how concentrated is the registry among the most prolific sponsors, and how
-- long is the tail of one-study sponsors? The lead figure: 71.4% of the
-- 589,453 registered studies are led by academic, hospital, and foundation
-- sponsors (the "Other" class), against 22.1% led by industry. A sponsor count
-- is a record of who registers research — NOT a quality, fraud, or wrongdoing
-- signal of any kind, and says nothing about any investigator, sponsor, or
-- provider.
--
-- Source:
--   public.clinical_trials — ClinicalTrials.gov Data API v2 (the U.S. National
--     Library of Medicine registry of interventional and observational
--     studies). 589,453 registered studies across 50,756 distinct lead
--     sponsors; snapshot 2026-06-14. Public, read-only. License:
--     ClinicalTrials.gov Terms & Conditions (NLM public data).
--     methodology_version = 'clinicaltrials/v1'.
--
-- Universe: this study reads the published registry AS A WHOLE — every row is a
--   study NLM lists on ClinicalTrials.gov as of the 2026-06-14 snapshot. The
--   registry is global in coverage: it includes trials sponsored from outside
--   the United States as well as U.S.-based research.
--
-- Counting note: 589,453 distinct NCT IDs, one row each; no row is duplicated.
--   "Sponsor" = lead_sponsor_name; sponsor "class" = lead_sponsor_class as the
--   registry codes it (OTHER = academic / hospital / foundation; INDUSTRY;
--   NIH; FED = other U.S. federal; OTHER_GOV; NETWORK; INDIV; etc.). No
--   individual investigator, sponsor, or provider is named, ranked, or scored
--   in the published study.

-- ============================================================================
-- (1) Universe reconciliation — the registry at a glance.
-- ============================================================================
SELECT
  count(*)                                                          AS studies,
  count(DISTINCT nct_id)                                            AS distinct_nct,
  count(DISTINCT lead_sponsor_name)                                 AS sponsors,
  count(*) FILTER (WHERE study_type = 'INTERVENTIONAL')             AS interventional,
  count(*) FILTER (WHERE study_type = 'OBSERVATIONAL')              AS observational,
  max(ingested_at)::date                                            AS snapshot
FROM public.clinical_trials;
--  studies 589,453 · distinct_nct 589,453 · sponsors 50,756
--  interventional 449,800 (76.3%) · observational 137,624 (23.3%) · snapshot 2026-06-14

-- ============================================================================
-- (2) HEADLINE: who runs the registry — share of all 589,453 studies by lead
--     sponsor class. Academic / hospital / foundation sponsors (OTHER) run
--     71.4%; industry runs 22.1%; the three government classes combined
--     (NIH + FED + OTHER_GOV) run 5.4%. The registry is led by universities and
--     hospitals, not pharma.
-- ============================================================================
SELECT
  coalesce(lead_sponsor_class, '(uncoded)')                         AS sponsor_class,
  count(*)                                                          AS studies,
  round(100.0 * count(*) / 589453, 1)                               AS pct_of_registry
FROM public.clinical_trials
GROUP BY sponsor_class
ORDER BY studies DESC;
--  OTHER     420,647 · 71.4%      INDUSTRY  130,207 · 22.1%
--  OTHER_GOV  15,564 ·  2.6%      NIH        11,536 ·  2.0%
--  NETWORK     4,966 ·  0.8%      FED         4,890 ·  0.8%
--  (uncoded)     975 ·  0.2%      INDIV         566 ·  0.1%
--  UNKNOWN        99 · ~0%        AMBIG           3 · ~0%
--  government combined (NIH + FED + OTHER_GOV) = 31,990 = 5.4%

-- ============================================================================
-- (3) THE INVERSION: who runs the regulated drug-development pipeline. Restrict
--     to PHASED interventional trials (Early Phase 1 .. Phase 4) — the trials
--     that test a drug or biologic in humans. Industry's share JUMPS from 22.1%
--     of all studies to 41.2% of phased trials; the OTHER class falls from
--     71.4% to 51.7%. Industry concentrates where the regulatory stakes are.
-- ============================================================================
SELECT
  coalesce(lead_sponsor_class, '(uncoded)')                         AS sponsor_class,
  count(*)                                                          AS phased_trials,
  round(100.0 * count(*) / sum(count(*)) OVER (), 1)                AS pct_of_phased
FROM public.clinical_trials
WHERE study_type = 'INTERVENTIONAL'
  AND phase IN ('EARLY_PHASE1','PHASE1','PHASE1/PHASE2','PHASE2',
                'PHASE2/PHASE3','PHASE3','PHASE4')
GROUP BY sponsor_class
ORDER BY phased_trials DESC;
--  OTHER     113,926 · 51.7%      INDUSTRY  90,723 · 41.2%
--  NIH         7,049 ·  3.2%      OTHER_GOV  3,983 ·  1.8%
--  NETWORK     2,722 ·  1.2%      FED        1,412 ·  0.6%
--  total phased interventional = 220,186

-- ============================================================================
-- (4) CONCENTRATION at the top — share of the registry run by the N most
--     prolific lead sponsors. The top 100 sponsors (0.2% of the 50,756) run
--     26.2% of all studies; the top 1,000 run 62.7%. "Top N" is a concentration
--     metric over the sponsor count distribution; no individual sponsor is
--     named.
-- ============================================================================
WITH s AS (
  SELECT count(*) AS c FROM public.clinical_trials GROUP BY lead_sponsor_name
),
r AS (SELECT c, row_number() OVER (ORDER BY c DESC) AS rn FROM s)
SELECT
  count(*)                                          AS sponsors,
  sum(c)                                            AS studies,
  sum(c) FILTER (WHERE rn <= 10)                    AS top10_studies,
  round(100.0 * sum(c) FILTER (WHERE rn <= 10)   / sum(c), 1)  AS top10_pct,
  sum(c) FILTER (WHERE rn <= 50)                    AS top50_studies,
  round(100.0 * sum(c) FILTER (WHERE rn <= 50)   / sum(c), 1)  AS top50_pct,
  sum(c) FILTER (WHERE rn <= 100)                   AS top100_studies,
  round(100.0 * sum(c) FILTER (WHERE rn <= 100)  / sum(c), 1)  AS top100_pct,
  sum(c) FILTER (WHERE rn <= 1000)                  AS top1000_studies,
  round(100.0 * sum(c) FILTER (WHERE rn <= 1000) / sum(c), 1)  AS top1000_pct
FROM r;
--  sponsors 50,756 · studies 589,453
--  top10 35,523 (6.0%) · top50 104,569 (17.7%)
--  top100 154,542 (26.2%) · top1000 369,564 (62.7%)

-- ============================================================================
-- (5) FRAGMENTATION at the bottom — the long tail. 53.8% of all lead sponsors
--     registered exactly one study; 82.4% registered five or fewer. The median
--     sponsor is a one-time registrant. Concentration at the top and a vast
--     thin tail are two faces of the same distribution.
-- ============================================================================
WITH s AS (
  SELECT count(*) AS c FROM public.clinical_trials GROUP BY lead_sponsor_name
)
SELECT
  count(*)                                          AS sponsors,
  count(*) FILTER (WHERE c = 1)                      AS one_study,
  round(100.0 * count(*) FILTER (WHERE c = 1) / count(*), 1)   AS one_study_pct,
  count(*) FILTER (WHERE c <= 5)                     AS five_or_fewer,
  round(100.0 * count(*) FILTER (WHERE c <= 5) / count(*), 1)  AS five_or_fewer_pct
FROM s;
--  sponsors 50,756 · one_study 27,328 (53.8%) · five_or_fewer 41,799 (82.4%)

-- ============================================================================
-- (6) WHO is at the top — the CLASS composition of the 100 most prolific
--     sponsors (aggregate; no sponsor named). 79 of the 100 are academic /
--     hospital / foundation sponsors, and they account for 73.3% of all
--     top-100 studies. The concentration at the head of the registry is
--     academic, not industrial.
-- ============================================================================
WITH s AS (
  SELECT lead_sponsor_class, count(*) AS c
  FROM public.clinical_trials GROUP BY lead_sponsor_name, lead_sponsor_class
),
r AS (SELECT lead_sponsor_class, c, row_number() OVER (ORDER BY c DESC) AS rn FROM s)
SELECT
  coalesce(lead_sponsor_class, '(uncoded)')         AS sponsor_class,
  count(*)                                          AS sponsors_in_top100,
  sum(c)                                            AS their_studies,
  round(100.0 * sum(c) / 154542, 1)                 AS pct_of_top100
FROM r
WHERE rn <= 100
GROUP BY sponsor_class
ORDER BY their_studies DESC;
--  OTHER 79 · 113,214 · 73.3%      INDUSTRY 16 · 31,517 · 20.4%
--  NIH    3 ·   7,111 ·  4.6%      FED       1 ·  1,725 ·  1.1%
--  (uncoded) 1 · 975 · 0.6%
