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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

CONNECT BY SQL Puzzler

Joseph UpshawJun 26 2014 — edited Jun 27 2014

Before I even start...I did not create this data model nor do I have any capability to change it. So, please no responses intended merely to explain how screwed up it is...I know.

Here's the issue.

A group may be comprised of either blurgs or other groups. So, I have three tables:

BLURG
BLURG_ID
BLURG_NAME

GROUP
GROUP_ID
GROUP_NAME

MEMBERSHIP_MAP
PARENT_GROUP_ID
MEMBER_GROUP_ID
MEMBER_BLURG_ID

So, whenever the MEMBER_GROUP_ID is populated, the MEMBER_BLURG_ID will be NULL and whenever the MEMBER_BLURG_ID is populated the MEMBER_GROUP_ID will be null.

The output we're looking for will show the groups that are directly assigned to the Blurg as well all groups that are indirectly assigned to the Blurg.

For example, Blurg Joe belongs to the PL/SQL Developers group. The PL/SQL Developers Group belongs to the Developers Group. The Developers Group belongs to the Nerd group. The Nerd group has no parent.

Blurg Joe also belongs to the Golfers group which has no parent.

So, what we'd want to see is something like this.

BLURG_NAMEGROUP_NAMELevel
JoePL/SQL Developers Group1
JoeDevelopers2
JoeNerd3
JoeGolfers1

How?

We can't seem to figure out what to use for the CONNECT BY clause because the first level are those Groups that are directly assigned to the Blurg and afterward, further up the hierarchy, Groups are connected to other Groups.

Thanks,

-Joe

This post has been answered by Chris Hunt on Jun 27 2014
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 25 2014
Added on Jun 26 2014
5 comments
2,082 views