How can I select all rows based on the AVG calculated in another column?

Franta

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

Gordon Linoff

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.

edited at
0

Comments

0 comments
Login to comment

Related

How can I add a calculated column based on another column in an SQL select statement

How can I select all the rows which do not share a column value with another row which is null?

How can I select all my column rows with the sum(column)

How can I combine rows in postgres when a column value is the same, and sum another column based on the combined rows?

How can I add a calculated column with different rows to a dataframe?

How to add calculated column based on values in rows

How can I create a new column in a pandas dataframe that counts backwards the rows based on the value of another column?

How can I drop consecutive duplicate rows in one column based on condition/grouping from another column?

How can I SELECT rows with MAX(Column value), PARTITION by another column in MYSQL?

How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?

How can I average every 5 rows specific column and select last data from another column in Pandas

How can I select rows corresponding to the unique pair of column values with the highest value of another column in PostgreSQL?

In MySQL, how can I SELECT a column ONLY if all rows in that column are not null

How do I select all rows with a minimum value that meet a condition in another column pandas

how to select rows in pandas dataframe based on between from another column

Creating calculated column based on another calculated column

mySQL: Can I add a calculated column with the sum of all other rows that have that same shared value

How can I select top k rows based on another dataframe in python?

How can I filter for pandas columns or rows based on values of another column?

How can a I drop duplicate rows for a dataframe based on the filter or condition of another column?

How can I select a data from another column from rows that have been selected?

How can I select distinct rows with max values on another column in Access 2016

How can I find all rows whose string value appears in a column of another table?

How can I use calculated values by formula in a new column for other rows in new column in R?

How do I select column based on value in another column with dplyr?

How can I select rows with all Column value, which have the same values?

In standard SQL, how do I select rows such that for each unique value in one column, all of the values in another column are a specified value?

How can I condense multiple SELECT statements into one when the value is based on the value in another column?

Postgres - How to use the AVG of the last number of rows and multiply it with another column?