• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

want to select max number over 4 columns

Hello

I have a data set from my query as per the following
Company    Value1     Value2     Value3     Value4
A                    5                 2              0              0
B                    0                  12           0             45
C                    0                  0             0              0
D                   12                 1             88           4  etc etc

What I want is to include another column which gives me the max value in each row - or - just return the max value per row for each customer - eg
Company    Max
A                    5          
B                   45
C                    0      
D                   88

Regards
0
PHIL Sawyer
Asked:
PHIL Sawyer
  • 2
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
select company, greatest(value1, value2, value3, value4) from table;
0
 
PHIL SawyerAuthor Commented:
Didn't know greatest existed - Thanks
0
 
slightwv (䄆 Netminder) Commented:
No problem.

Whenever you have a few minutes, it's always worth the time to just scan the SQL docs from time to time.

Just scanning the available functions can make you click on them to see what they do.  You will learn a lot...
0
 
PHIL SawyerAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now