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!

unique filter from listagg

user12983407Sep 2 2014 — edited Sep 2 2014

Hello All,

I wrote below SQL using LISTAGG function, but it is giving me duplicate value as shown below.. I also mention here expected output.

SELECT DISTINCT ppg.profile_id AS pid,
LISTAGG ( vegb.bu_id, ',') WITHIN GROUP (

  ORDER BY vegb.bu_name) AS bu_id,

LISTAGG (vegb.bu_name, ',') WITHIN GROUP (

  ORDER BY vegb.bu_name) AS bu_name

  FROM profile_data pd,

PROFILE_PLATFORM_GROUPS ppg,
V_EQUIPMENT_GROUP_BU vegb
  WHERE pd.profile_id   = ppg.profile_id

  AND ppg.verifier_group_id = vegb.verifier_group_id

  GROUP BY ppg.profile_id;

Current Result as below:

PID      BU_ID                                         BU_NAME

------------------------------------------------------------------------------------------------------------------------ 

1141    1000,1000,1000,1000,1000,1000   Corporate,Corporate,Corporate,Corporate

1151    1000                                           East London Team

2046    1075                                           Access,Corporate

2276    1000,1000,1025                           Corporate,Corporate,FTTx I&R

Expected Result as below:

PID      BU_ID                                         BU_NAME

------------------------------------------------------------------------------------------------------------------------ 

1141    1000                                           Corporate

1151    1000                                           East London Team

2046    1075                                           Access,Corporate

2276    1000,1000,1025                           Corporate,FTTx I&R

This post has been answered by Manik on Sep 2 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 30 2014
Added on Sep 2 2014
2 comments
1,075 views