Solved

want to select max number over 4 columns

Posted on 2013-10-23
4
356 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.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now