Help in a store procedure

  • Hi,

    I have a Stored procedure with many instructions among which this one

    select cmp_id from CSR_COMPLEMENT

    where DOS_ID = (select DOS_ID from CSR_DOSSIER where DOS_NODE = @DOS_NODE) order by cmp_numordre

    if the number of row is 01, i can easily get the cmp_id, now how can i get the cmp_id when the number of row is more than one? in this case the cmp_id to take is the one with the higher cmp_numordre. from the result, I writing a new sql.

    thanks

  • select top 1 cmp_id from CSR_COMPLEMENT

    where DOS_ID = (select DOS_ID from CSR_DOSSIER where DOS_NODE = @DOS_NODE) order by cmp_numordre desc

    Might be missing something but if you only want 1 cmp_id based on the highest cmp_numordre, the above should work.

  • http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/a9bcde36-408d-4ddf-b62e-132c257e9362/

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • did I miss something ?

    I guess i didn't get the question ...

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • hi,

    MERCI

Viewing 5 posts - 1 through 4 (of 4 total)

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