| 
	
 | 
 Posted by Kimmo Laine on 06/13/52 11:26 
This is fucking ridiculous, but I can't seem to get this working.... I want  
to use if-statement inside a query. I remember clearly that something like  
this would actually work in MySQL, but so far I haven't got it working in  
MSSQL. 
 
Trying something like 
"SELECT IF(dsum > 100, 100, dsum) as dsum_2 from view1" 
 
Meaning, that if the particular row has dsum larger than 100, then output  
100, but if it's less than 100, then output whatever dsum is. Doesn't work.  
Parse errors are all I get. I'm basicly trying to select the smaller of 100  
and dsum. dsum is something between 0...120. 
 
Like this: 
dataset | result of select 
dsum    | dsum_2 
--------------- 
100     | 100 
50      | 50 
120     | 100 
75      | 75 
105     | 100 
 
 
Thanks in advance 
 
--  
Welcome to Usenet! Please leave tolerance, understanding 
and intelligence at the door. They aren't welcome here. 
eternal piste erection miuku gmail piste com
 
  
Navigation:
[Reply to this message] 
 |