For Pick Up Max value From Table

  • How i can get max value from Table like CustId withour using Max() Function

  • Hi Tushar..

    You could write a loop and scan all of your records to find the MAX() value, but that will certainly be more expensive than using the MAX() function.

    Is this an intellectual exercise or is there a reason you're reluctant to use MAX()?


    Take care..

    - Ward Pond
    blogs.technet.com/wardpond

  • Select Top 1 CustID

    from <TableName>

    Group by CustID

    Sort by Desc

    or

    Select Max(CustId)

    from <TableName>

     

  • The first alternative would probably be more efficient as an ORDER BY CustID DESC but it's a good call..


    Take care..

    - Ward Pond
    blogs.technet.com/wardpond

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

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