TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ishan
NA
9
0
Parent Child SQL QUERY PROBLEM
Jul 7 2010 8:50 AM
I am using MS SQL server, I have this table
aid ans parent
----------- ---------- -----------
1 a 0
2 b 1
3 c 1
4 d 0
5 e 0
6 f 4
7 g 4
8 h 1
9 i 5
10 j 5
11 k 0
12 l 6
13 m 2
I need this output
aid is primary key,ans in some text, parent is parent child relationship. parent value 0 means it is on head level, parent value 1 means its parent is having aid= 1, parent value 6 means its parent is having aid=6 and I hv to arrange in hierarchical order of parent child like as shown below. I need query for this, Plz help
aid ans parent
1 a 0
2 b 1
13 m 2
3 c 1
8 h 1
4 d 0
6 f 4
12 l 6
7 g 4
5 e 0
9 i 5
10 j 5
11 k 0
Reply
Answers (
2
)
How to Give unique user id when many users registered at same time
problem in sql reporting service