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
 Transact-SQL (2000)
 Needed a help in writing SELECT Query

Author  Topic 

3deepak
Starting Member

2 Posts

Posted - 2008-07-07 : 23:42:18
hi all,

Let us consider I have a table, tbl1, like this

prevID prevName NextID NextName Value
1 name1 2 name1 100
1 name1 2 name2 200
2 name1 3 name1 300
2 name2 4 name2 400
3 name1 4 name2 500
4 name1 2 name2 600
4 name2 4 name1 700

Now, I want to extract Value from this table.If I give the prevID and prevName, then my query should extract
1) all the Value for the prevID & prevName combination
2) all the Value for the NextID and NextName combination available till the cycle completes.

For eg, suppose if i give prevID =1 and prevName = 'name1' then the Values extracted should be in the order

Value
100
300
500
700
600
400
200


to give another eg, suppose if i give prevID =3 and prevName = 'name1' then the Values extracted should be in the order

Value
500
700
600
400


I hope you understood the logic.. Please help me on the query for this.. I tried hard but I'm not able to find it...Thanks...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-08 : 06:40:25
have a look at this:-
http://support.microsoft.com/kb/248915
Go to Top of Page

3deepak
Starting Member

2 Posts

Posted - 2008-07-08 : 07:06:15
Thank you very much... this is what I'm searching about!! :)
Go to Top of Page
   

- Advertisement -