MrTV
asked on
number of reference mysql write sql in my sql to get the rank
the table below show
nae is ahead of michale , cheery, victoria
susan is ahead of nae
david is ahead of susan
id robert headid
1 david
2 nae 4
3 michale 2
4 susan 1
5 cheery 2
6 victoria 2
7 michele 2
8 nicole 3
9 taylor 2
10 rossom 2
how can I write the code in sql to show
name rank
david 3
susan 2
nae 1
etc
nae is ahead of michale , cheery, victoria
susan is ahead of nae
david is ahead of susan
id robert headid
1 david
2 nae 4
3 michale 2
4 susan 1
5 cheery 2
6 victoria 2
7 michele 2
8 nicole 3
9 taylor 2
10 rossom 2
how can I write the code in sql to show
name rank
david 3
susan 2
nae 1
etc
Can you explain more about on what basis you would like to generate the Rank.
ASKER
a is a head of b
b is a head of c
c is the head of d
rank
c 1
b 2
a 3
b is a head of c
c is the head of d
rank
c 1
b 2
a 3
ASKER
a is a head of b b is a head of c c is the head of d
rank
c 1
b 2
a 3
I have colum name and Hid (hierarchy id)
Hid related to id
id name Hid
1 a
2 b 1
3 c 2
4 d 3
5 f
6 g 5
How can I use sql statement to find this table
rank
c 1
b 2
a 3
f 1
rank
c 1
b 2
a 3
I have colum name and Hid (hierarchy id)
Hid related to id
id name Hid
1 a
2 b 1
3 c 2
4 d 3
5 f
6 g 5
How can I use sql statement to find this table
rank
c 1
b 2
a 3
f 1
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.