Build a Dividend Income Tracker With SQL
Yield on cost against current yield, per positionranking ·
2026-10-08 · 6×3
Annual dividend income per position, with a running portfolio totalranking ·
2026-10-08 · 6×3
What the sample list paid per calendar year, share counts held fixedranking ·
2026-10-08 · 5×3
Projected dividend income by month, next twelve monthsseries ·
2026-10-08 · 13×4
Latest declared dividend per share for each sample holdingtable ·
2026-10-08 · 6×5
Relative Volume Screener in SQL: Free API
Share of a session's volume completed by each half hour: SPY and KOseries ·
2026-10-04 · 13×3
Relative volume screener: top 20 by time adjusted RVOL at 11:00 a.m. ETtable ·
2026-10-04 · 20×5
Cisco, September 22, 2026: naive RVOL against time adjusted RVOL through the sessionseries ·
2026-10-04 · 13×3
Share of the session completed by 11:00 a.m. ET, twelve household namesranking ·
2026-10-04 · 12×3
Iron Condor Screener from the SQL API
How many of each week's candidates still cleared a week laterseries ·
2026-10-04 · 11×5
Survivors as the credit floor and the delta band moveranking ·
2026-10-04 · 5×4
Where each underlying's implied volatility sits in its own yearranking ·
2026-10-04 · 6×4
One chain, one expiration: delta at every 5 point striketable ·
2026-10-04 · 17×5
Iron condor candidates that cleared every filtertable ·
2026-10-04 · 6×7
Covered Call Screener: Build One in SQL
The covered call screen, ranked by annualised yield, last session of August 2026table ·
2026-09-26 · 12×8
The same screen replayed monthly, and how the selected calls finishedseries ·
2026-09-26 · 11×5
Annualised call premium at 0.25 to 0.35 delta, eight liquid names, August 2026ranking ·
2026-09-26 · 8×4
AAPL call premium yield by delta band, August 2026table ·
2026-09-26 · 6×5
Yield on cost against current yield, per position
Yield on cost against current yield, per position
| ticker | yield_on_cost_pct | current_yield_pct |
|---|---|---|
| O | 5.27 | 6.11 |
| XOM | 4.28 | 2.46 |
| KO | 3.92 | 2.46 |
| JNJ | 3.45 | 2.08 |
| PG | 3.08 | 2.94 |
| MSFT | 1.46 | 0.74 |
the exact SQL behind every number
WITH holdings AS
(
SELECT
tupleElement(h, 1) AS ticker,
tupleElement(h, 2) AS cost_per_share
FROM
(
SELECT arrayJoin([
('KO', 54.10),
('PG', 141.25),
('JNJ', 155.40),
('MSFT', 268.75),
('XOM', 96.20),
('O', 61.85)
]) AS h
)
),
declared AS
(
SELECT
ticker,
argMax(cash_amount, ex_dividend_date) AS cash_per_payment,
argMax(frequency, ex_dividend_date) AS pays_per_year
FROM global_markets.stocks_dividends
WHERE ticker IN ('KO', 'PG', 'JNJ', 'MSFT', 'XOM', 'O')
AND currency = 'USD'
AND frequency IN (1, 2, 4, 12)
AND ex_dividend_date >= today() - 400
AND ex_dividend_date <= today() + 120
GROUP BY ticker
),
last_px AS
(
SELECT
ticker,
argMax(toFloat64(close), date) AS last_close
FROM global_markets.stocks_daily_aggs
WHERE ticker IN ('KO', 'PG', 'JNJ', 'MSFT', 'XOM', 'O')
AND date >= today() - 45
GROUP BY ticker
)
SELECT
h.ticker AS ticker,
round(toFloat64(d.cash_per_payment) * d.pays_per_year / h.cost_per_share * 100, 2) AS yield_on_cost_pct,
round(toFloat64(d.cash_per_payment) * d.pays_per_year / p.last_close * 100, 2) AS current_yield_pct
FROM holdings AS h
INNER JOIN declared AS d ON d.ticker = h.ticker
INNER JOIN last_px AS p ON p.ticker = h.ticker
ORDER BY yield_on_cost_pct DESC
More from this analysisBuild a Dividend Income Tracker With SQL
Annual dividend income per position, with a running portfolio total
ranking 6×3
→
What the sample list paid per calendar year, share counts held fixed
ranking 5×3
→
Projected dividend income by month, next twelve months
series 13×4
→
Latest declared dividend per share for each sample holding
table 6×5
→
See all 3,214 queries →