Advertisement

05.30.2008 at 11:29AM PDT, ID: 23445561
[x]
Attachment Details

sql question 5

Asked by rutledgj in PL / SQL, SQL Server 2005

Consider the following flattened hiearchy table for employees

ParentID      ParentName         ChildLevel         ChildID     ChildName
01                Ann                         1                       01           Ann  
01                Ann                         2                       02           Brenda
01                Ann                         3                       03           Carl
01               Ann                          2                       04           Dave
01               Ann                          3                        05           Ebert
02               Brenda                     4                        03           Carl
04               Dave                        4                        05           Ebert


The ChildLevel indicates the tree level (Hiearchy).  So Ann is the top level manager. Brenda and Dave work for Ann. Carl works for Brenda, Ebert works for Dave.

I want sql that will return all of these people grouped properly so in a report it will look like this:

Ann          
           Brenda
                  Carl
           Dave
                  Ebert


Basically a drill-down report. So I need a NodeLevel and the name so I know how to group them. The root id for Ann is passed in.

I need a solution for both oracle and sql server.Start Free Trial
 
 
[+][-]05.30.2008 at 11:36AM PDT, ID: 21680290

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 11:36AM PDT, ID: 21680304

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 11:59AM PDT, ID: 21680482

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 12:06PM PDT, ID: 21680546

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 12:10PM PDT, ID: 21680588

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PL / SQL, SQL Server 2005
Sign Up Now!
Solution Provided By: Miss_Sellaneus
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628