SingleStore DB

Query 3

Finds the most volatile stocks (highest variance in prices) in the last 5 seconds.

SELECT stock_symbol, VARIANCE(share_price) var
  FROM trade
  WHERE trade_time * 1 > ( NOW() - 5 )
  GROUP BY stock_symbol
  ORDER BY var DESC;