MSSQL 2000

  • I have a single table "amount" which has only three columns such as memberid referenceid and AMOUNT with following data ........

    memberid referenceid AMOUNT

    L001 L001

    L004 L003

    L003 L002

    L002 L001

    and so on

    my needed query willbe if i choose L003 from referenceid the query should select the column where it was a memberid and again it choose the same row refernceid of(L003) as L002 where L002 was a memberid and choose L002s referenceid which is L001

    Finally i should REACH the memberid(L001) and

    the other one i need is i should return the count of no of rows crossed ,

    and my biq question is everytime the query gets into new row i should add some data in amount (50,25,12.5,10,7.5,5,4,3,2,1)for (immediate row,next row,next row and so on)

    how can i do this in MSSQL2000??

    I have crossed accross many forums pls help im stuck up

  • Lookup "hierarchical queries [SQL Server]" in Books Online... what you're asking for is how to expand a hierarchy...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply