Solved

want to select max number over 4 columns

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
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 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
Via a live example, show how to take different types of Oracle backups using RMAN.

911 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

17 Experts available now in Live!

Get 1:1 Help Now