Results 1 to 2 of 2

Thread: Finding max and sum in a row

  1. #1
    Join Date
    Apr 2009
    Posts
    8

    Finding max and sum in a row

    Hello;
    I have a table:

    Code:
    ID     Cat1       Cat2      Cat3
    1                    4           2
    2      3                         1
    3      7            3           2
    4                                5
    I need to create an ouput like this:
    Code:
    ID     Cat1       Cat2      Cat3      MaxValue        Sum
    1                    4           2          4                   6
    2      3                         1          3                   4
    3      7            3           2          7                   12
    4                                5          5                   5
    Any suggestions?
    Thanks!

  2. #2
    Join Date
    Apr 2009
    Posts
    86
    yesmein, Try something like:
    Code:
    SELECT ID, Cat1,  Cat2,  Cat3
         , MAX(Cat1,  Cat2,  Cat3) AS MAXVALUE
         ,    (Cat1 + Cat2 + Cat3) AS SUMVALUE

Posting Permissions

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