Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Max from multiple column and Group by

Orcl ApexSep 21 2019 — edited Sep 22 2019

Hi,

There is small change in requirement from last thread as below - (added one more column as data)

WITH t AS (

SELECT 'A' Data, '01-JAN-19' as dates, 1 as first, 2 as second, 3 as third FROM DUAL UNION ALL

SELECT 'A', '02-JAN-19' as dates, 3 as first, 9 as second, 200 as third FROM DUAL UNION ALL

SELECT 'A', '03-JAN-19' as dates, 10 as first, 8 as second, 30 as third FROM DUAL UNION ALL

SELECT 'B', '02-JAN-19' as dates, 3 as first, 9 as second, 200 as third FROM DUAL UNION ALL

SELECT 'B', '03-JAN-19' as dates, 10 as first, 8 as second, 30 as third FROM DUAL

) SELECT * FROM t;

Requirement -

200 is maximum in these three columns so I want result as below, Date, Max Value and half of max value.

A 02-JAN-19, 200, 100

B 02-JAN-19, 200, 100

This post has been answered by mathguy on Sep 22 2019
Jump to Answer
Comments
Post Details
Added on Sep 21 2019
3 comments
7,077 views