Jump to content

SQL Select Statement with decimal search


CHITOWN
 Share

Recommended Posts

Is there a way to write a query that has a decimal column, currently set to .nn, to give me results that the hundredths column doesn't end in zero in the hundredths column and excludes .25, .75.   For example, finding .35 but not .25 or finding .83 but not .80.   Any select statement to find those records is what I am looking for as I have tried where cast(hours as decimal(10,2)) - hours > 0 
 but brings me back decimals ending in zero as well as .25 and .75.   Thanks.
 

Link to comment
Share on other sites

Use many BETWEEN operators with an OR between each BETWEEN if you want do it with SQL.

I'd use one BETWEEN and process the resulting array with a php loop.

https://www.w3schools.com/sql/sql_between.asp 

 

 

Edited by niche
Link to comment
Share on other sites

I should give example of values in calculations, 'hours' means nothing unless you actually identify what the value actually is.

You can use IN or NOT IN to get specific values ex. NOT IN(.0, .00,.25,.75,.80) you could remove the decimal point from value to test against, and NOT IN values.

Removing portion of value RIGHT(), SUBSTRING()

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...