Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

display numbers 0-9 Expand / Collapse
Author
Message
Posted Friday, August 8, 2014 12:05 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 6, 2015 6:22 AM
Points: 251, Visits: 608
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,
Post #1601031
Posted Friday, August 8, 2014 12:18 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 21, 2015 7:48 AM
Points: 1,023, Visits: 1,783
Sample data and Desire Output will be very helpful to understand the problem and its solution.
Post #1601035
Posted Friday, August 8, 2014 7:25 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 7:12 AM
Points: 1,067, Visits: 3,246
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

@SeanPearceSQL

About Me
Post #1601163
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse