Domanda

I have a query that should display some data based on certain criteria.

When displaying data I have the following condition in my query:

cast(percentage as float)/100 < 0.50) which should give me values less then 50%.

However, when executing the query it gives me values like 95, 100...but never gives me less than 0.50, even though I specified condition in a query.

When doing a single select from the table to check what value is there, I'm getting 0.95:

select cast(percentage as float)/100 from table1 where id ='1111'

What am I doing wrong? And what is the solution?


This is my where clause:

WHERE msystem = '111'
AND (
     (code = '2222' AND cast(percentage as float)/100 < 0.50)
     OR   (code = '3333')
     )
È stato utile?

Soluzione

This code here:

(code = '2222' AND cast(percentage as float)/100 < 0.50)
     OR   (code = '3333')

That second piece of the OR (code = '3333') is allowing for results that are greater than 0.50

The way you have your where clause written right now it shows you any results that have code = '3333' and only results that have code = '2222' that are less than 0.50

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top