Solved

want to select max number over 4 columns

Posted on 2013-10-23
4
359 Views
Last Modified: 2013-10-23
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
Comment
Question by:PHIL Sawyer
  • 2
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39594474
select company, greatest(value1, value2, value3, value4) from table;
0
 

Author Comment

by:PHIL Sawyer
ID: 39594508
Didn't know greatest existed - Thanks
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39594516
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
 

Author Comment

by:PHIL Sawyer
ID: 39594528
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question