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!

different values on same grouping column

954475Jun 19 2015 — edited Jun 19 2015

Hi all,

I have a requirement of finding different records of same grouping columns have different value values in columns for example:

WITH

Data(G1, COL)

AS

(

 SELECT 'A',    '456' FROM Dual UNION ALL

 SELECT 'A',    '345' FROM Dual UNION ALL

 SELECT 'A',    ' '  FROM Dual UNION ALL

 SELECT 'B',   '123' FROM Dual UNION ALL

 SELECT 'B',   '123' FROM Dual UNION ALL

 SELECT 'B',   '123 '  FROM Dual UNION ALL

 SELECT 'C',   '789' FROM Dual UNION ALL

 SELECT 'C',   '789' FROM Dual UNION ALL

 SELECT 'C',   ' '  FROM Dual

 )

select g1, col from Data

ideally for G1 = A, COL should has only one value across all records either '456' or '345'. So I need to check in NOT NULL values of COL where for any value of G1 we have different values of COL. G1='B' is perfectly fine so I don't need it. G1=C is also fine and I am not worried about it. I only need those entries where Col has different non blank / Not NULL value for same value of G1.

So expected out put is

Capture.PNG

This post has been answered by Solomon Yakobson on Jun 19 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2015
Added on Jun 19 2015
5 comments
598 views