Goldy714
Goldy714

Reputation: 1

Oracle SQL select records where percentage of one column is above a certain amount

I have two columns of data and I need to select only the rows where the percentage is above a certain percentage of another (say 80%). So in the table below the only records selected would be rows 2 and 4 in the table pic. I also need to avoid any rows where either value is = 0.

Table

I have tried using ratio_to_report but just can't seem to make it work. Any help appreciated.

Upvotes: 0

Views: 175

Answers (2)

Shekhar
Shekhar

Reputation: 51

select * from job_hours where Hours/"Est Hours">0.8 and "Est Hours"<>0

Upvotes: 0

Dr Phil
Dr Phil

Reputation: 880

The percentage is a ratio of two values per 100. So the formula would be percentage=Hours/Est Hours x 100. Conversely 80% would be a ratio of 0.8. So your where condition could be Hours/"Est Hours">0.8. Please note that since your column name has a space it has to be enclosed in double quotes.

select * from table where Hours/"Est Hours">0.8

Upvotes: 1

Related Questions