简体   繁体   中英

Compare two values in SQL with a comparison in between columns

I have two columns to compare. I am writing a query in Oracle SQL

I need a query to check the value of the first column if it is between +/- 5% of the second column.

Ex: If value in column B is 500, Column A should be between 525 and 475

Try this:

SELECT * FROM your_table
WHERE a BETWEEN b*0.95 AND b*1.05

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM