ELI
ELI

Reputation: 369

sql: filter rows based on conditions

How to write a sql query to return rows only the column value exceed at least 1% of the sum of the column, like

%sql select * from df1 where total_bytes>= 0.01*sum(total_bytes) order by total_bytes desc 

But this gave me errors.

Upvotes: 0

Views: 45

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522787

Use a subquery to compute the sum of the total_bytes column:

select *
from df1
where total_bytes >= 0.01*(select sum(total_bytes) from df1)
order by total_bytes desc

Upvotes: 1

Related Questions