display numbers 0-9

  • Hi,

    I am having query where i am calulating datediff value, but i want to display resultser as below:

    if datediff = 4 then resultset would be

    0

    1

    2

    3

    4

    if datediff = 9 then

    0

    1

    2

    3

    4

    5

    6

    7

    8

    9

    how can i implement this?

    Thanks

    ABhas,

  • Sample data and Desire Output will be very helpful to understand the problem and its solution.

  • WITH CTE AS (

    SELECT TOP 10000

    ROW_NUMBER() OVER (ORDER BY a.object_id) - 1 AS RowNbr

    FROM

    sys.all_columns a

    CROSS JOIN

    sys.all_columns b)

    SELECT

    RowNbr

    FROM

    CTE

    WHERE

    RowNbr <= DATEDIFF(HOUR, '2014-08-07 10:00', '2014-08-07 18:00')

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]

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

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