Jump to content

SQL Select Statement with decimal search

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 post
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.




Edited by niche
Link to post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...