I'm trying to select all the rows where the symbol meets the condition that AVG on column "volume" is greater than 100000. Something like -
SELECT * FROM etf_daily WHERE symbol, avg(volume)>1000000 GROUP BY symbol
I have this table enter image description here
You seem to want aggregation and a HAVING
clause:
SELECT symbol, avg(volume)
FROM etf_daily
GROUP BY symbol
HAVING AVG(volume) > 1000000 ;
EDIT:
Based on your comment, use window functions:
SELECT d.*
FROM (SELECT d.*,
AVG(volume) OVER (PARTITION BY symbol) as symbol_avg
FROM etf_daily d
) d
WHERE symbol_avg > 1000000 ;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments