Sample SQL Queries
Ready-to-run queries for Dolt, DuckDB, PostgreSQL, or any standard SQL engine.
1
Find all splits for a ticker
Returns every recorded stock split for a given symbol, ordered most recent first.
SELECT symbol, event_date, old_shares, new_shares, adjustment_factor FROM fact_corporate_action_event JOIN dim_symbol_alias ON fact_corporate_action_event.security_id = dim_symbol_alias.security_id WHERE action_type = 'SPLIT' AND symbol = 'RELIANCE' ORDER BY event_date DESC;
2
Get dividend-adjusted price series
Computes a backward-adjusted close price using cumulative dividend adjustment factors.
SELECT lineage_date, symbol, close_price, close_price / COALESCE( SUM(cumulative_dividend_adjustment) OVER ( PARTITION BY symbol ORDER BY lineage_date ), 1.0 ) AS adjusted_close FROM fact_equity_eod JOIN dim_symbol_alias ON fact_equity_eod.security_id = dim_symbol_alias.security_id WHERE symbol = 'INFY' ORDER BY lineage_date;
3
Track symbol name changes over time
Lists all renames, mergers, and delistings for securities matching a name pattern.
SELECT security_id, old_symbol, new_symbol, change_date, change_reason FROM fact_symbol_lineage_event WHERE security_id IN ( SELECT security_id FROM dim_security_master WHERE issuer_name LIKE '%Tech%' ) ORDER BY change_date DESC;
4
Identify broken backtests due to missing adjustments
Finds symbols with corporate action events that have no corresponding adjustment factor — a common source of silent backtest errors.
SELECT symbol, COUNT(*) AS missing_adjustments FROM fact_corporate_action_event WHERE security_id NOT IN ( SELECT security_id FROM fact_adjustment_factor ) AND action_type IN ('SPLIT', 'BONUS', 'DIVIDEND') GROUP BY symbol HAVING COUNT(*) > 0;