retrieving the greatest 10 negative numbers

  • Hi,

    I have table T1 with some columns

    e.g

    C1- ID

    C2-Date

    C3-Gross amount( positive and negative values)

    C4-Netamount

    I want to retrieve 10 IDs with the greatest negative Gross amount for the current date.

    Please can anyone help me in getting it.

    thanks

  • DECLARE @dtStartDate DATETIME,

    @dtEndDate DATETIME

    SET @dtStartDate = CONVERT( DATETIME, CONVERT( VARCHAR(10), GETDATE(), 112 ) )

    SET @dtEndDate = DATEADD( DAY, 1, @dtStartDate )

    SELECT TOP 10 ID

    FROM T1

    WHERE [Date] >= @dtStartDate AND [Date] < @dtEndDate

    AND [Gross amount] < 0

    ORDER BY [Gross amount] DESC

    --Ramesh


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

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