If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Regarding the DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-11-07, 04:57
yarapatineni yarapatineni is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
Regarding the DB2

Hi all,,

i want to know something about the case statement

supoose i have 10,432,456,32221,345 in this i want to find the max value using the case statement

if anybody have idea about this please let me know

Thanks,
satya
Reply With Quote
  #2 (permalink)  
Old 12-11-07, 06:53
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
answer: normalize your data, then use this --[code]select max(foo) from daTable[/b]
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-11-07, 07:37
yarapatineni yarapatineni is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
regarding the case function

Hi r,

max funtion gives the max value of the prticular column.

suppose i have 4 columns like

no1, no2,no3,no4
12 13 14 10
14 243 321 45

these are all the columns.. i want to find the max of the no1,no2,no3 and no4
the result is like this 14 and 321

thanks
satya
Reply With Quote
  #4 (permalink)  
Old 12-11-07, 07:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
my answer is still the same -- normalize your table
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 12-11-07, 09:33
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Or in other words: why do you want to find the maximum of values with completely different semantics?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 12-11-07, 10:21
jsharon1248 jsharon1248 is offline
Registered User
 
Join Date: Apr 2007
Location: Chicago
Posts: 57
You don't mention which version of DB2 you are using. DB2 for z/OS supports the MAX scalar function, so it would just be

Code:
SELECT max(col1,col2,col3)
  FROM <table>
 WHERE <predicates>
UDB for AIX does not support the MAX scalar function. I don't know about other versions.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On