quarterly_financials AS a JOIN ( SELECT ticker, MAX(fiscal_year) AS latest_fiscal_year, MAX(fiscal_quarter) AS latest_fiscal_quarter FROM quarterly_financials GROUP BY ticker ) AS latest ON a.ticker = latest.ticker AND a.fiscal_year = latest.latest_fiscal_year AND a.fiscal_quarter = latest.latest_fiscal_quarter ), 直近四半期の値とJOINして 最新値を持つレコードを特定
AS a JOIN ( SELECT ticker, MAX(date) AS latest_date FROM daily_indicator GROUP BY ticker ) AS latest ON b.ticker = latest.ticker AND a.date = latest.latest_date ) 最新日付の値とJOINして 最新値を持つレコードを特定
FROM latest_quarterly_financials lqf LEFT JOIN latest_daily_indicator ldi ON lqf.ticker = lsp.ticker LEFT JOIN listing_markets m ON lqf.ticker = listing_markets.ticker … 必要なデータをJOINしていく - 直近四半期の財務数値 - 最新日付の株価指標 - 市場の情報