Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2007
    Posts
    2

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    answer: normalize your data, then use this --[code]select max(foo) from daTable[/b]
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    my answer is still the same -- normalize your table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  6. #6
    Join Date
    Apr 2007
    Location
    Chicago
    Posts
    68
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •