| Author | Topic | 
                            
                                    | ramecepaStarting Member
 
 
                                        43 Posts | 
                                            
                                            |  Posted - 2010-08-30 : 00:07:56 
 |  
                                            | Dear all,i want to find highest value from 3 fieldsEX:field1   field2    field30        0          12        3          15        4          2Result135 |  | 
       
                            
                       
                          
                            
                                    | senthil_nagoreMaster Smack Fu Yak Hacker
 
 
                                    1007 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 01:47:55 
 |  
                                          | Select case when f1 > f2 and  f1 > f3 then f1when f2 > f3 then f2 else f3 end from fieldSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |  
                                          |  |  | 
                            
                       
                          
                            
                                    | ramecepaStarting Member
 
 
                                    43 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:06:17 
 |  
                                          | select case when piaprin > piaint > pialpi then piaprinwhen piaint > pialpi  then piaintelse pialpi end as ta from tbl_Aces1i have written like this ....getting error like Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '>'. |  
                                          |  |  | 
                            
                       
                          
                            
                                    | senthil_nagoreMaster Smack Fu Yak Hacker
 
 
                                    1007 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:14:29 
 |  
                                          | quote:Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/Originally posted by ramecepa
 select case when piaprin > piaint and piaprin > pialpi then piaprinwhen piaint > pialpi  then piaintelse pialpi end as ta from tbl_Aces1i have written like this ....getting error like Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '>'.
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | ramecepaStarting Member
 
 
                                    43 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:36:37 
 |  
                                          | Thanks bro, |  
                                          |  |  | 
                            
                       
                          
                            
                                    | sakets_2000Master Smack Fu Yak Hacker
 
 
                                    1472 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:39:54 
 |  
                                          | It mightn't work if columns are null. |  
                                          |  |  | 
                            
                       
                          
                            
                                    | senthil_nagoreMaster Smack Fu Yak Hacker
 
 
                                    1007 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:40:38 
 |  
                                          | quote:Welcome!Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/Originally posted by ramecepa
 Thanks bro,
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | senthil_nagoreMaster Smack Fu Yak Hacker
 
 
                                    1007 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:41:34 
 |  
                                          | quote:If the case ,we must use isnull(column_name,0)Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/Originally posted by sakets_2000
 It mightn't work if columns are null.
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | sakets_2000Master Smack Fu Yak Hacker
 
 
                                    1472 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:52:16 
 |  
                                          | What if you had 10 columns instead ?? That'd be a lot of combinations.Method 1 from this link is a better way to do this..http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86906 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | senthil_nagoreMaster Smack Fu Yak Hacker
 
 
                                    1007 Posts | 
                                        
                                          |  Posted - 2010-08-30 : 02:59:45 
 |  
                                          | quote:Ya ofcourse, but here the case no of columns are fixed and solution is acceptable!Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/Originally posted by sakets_2000
 What if you had 10 columns instead ?? That'd be a lot of combinations.Method 1 from this link is a better way to do this..http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86906
 
 |  
                                          |  |  | 
                            
                            
                                |  |