c# - How to compare three column in sql -


this question has answer here:

i want compare 3 column value comparison value col2 in table.

col1 col2 col3

12 < 25 true

25 > 20 true

15 = 25 false

select (case when col2 = '<'  col1 < col3 else  col1  end) 

can me ? advanced thanks.

you can try using case, this:

 case     when col2 = '<'      col1 < col3    when col2 = '>'      col1 > col3    when col2 = '='      col1 = col3  end case 

the query be

 select case            when col2 = '='             case when (col1 = col3) 1 else 0 end           when col2 = '>'             case when (col1 > col3) 1 else 0 end           when col2 = '<'             case when (col1 < col3) 1 else 0 end           else             0           end     mytable 

another possibily is

  (col2 = '<' , (col1 < col3)) or   (col2 = '>' , (col1 > col3)) or   (col2 = '=' , (col1 = col3))  

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -