Esproc, Data, Data Analysis, Development, Esproc Spl.
difficult to write in SQL: calculate the maximum consecutive days that a stock keeps rising. SELECT MAX(ContinuousDays) FROM (SELECT COUNT(*) ContinuousDays FROM (SELECT SUM(UpDownTag) OVER ( ORDER BY TradeDate) NoRisingDays FROM (SELECT TradeDate, CASE WHEN Price>LAG(price) OVER ( ORDER BY