Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Wanted a Sql Query

Author  Topic 

jrdatla
Yak Posting Veteran

51 Posts

Posted - 2001-01-15 : 18:49:01
I Have the following table.
GID PGID
1 <Null>
2 1
3 1
4 2
5 2
6 3
7 4
8 4
9 5
10 3
11 7
12 7
13 8

The record with GID = 1 is the parent Group and it has two sub groups 2, 3. The Subgroup 2 has 4,5 as its sub groups and Subgroup 3 has 6, 10 as its subgroup and the list continues so on.

I would like to have a query which shows the Sub Groups, subgroups within the subgroups for a asked group/subgroup.

Example: A query which returns the subgroups for GID = 2
Result: 4,5,7,8,9,11,12, 13.

Gid GubGroups
2 4, 5
4 7, 8
5 9
7 11, 12
8 13

So the query should return 4,5,7,8,9,11,12,13.

Thank you



Jr. Datla
   

- Advertisement -