Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: Thursday, August 4, 2016 8:01 AM
Points: 264, Visits: 634
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: Yesterday @ 6:26 AM
Points: 1,335, Visits: 2,518
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: Monday, August 22, 2016 6:17 AM
Points: 1,144, Visits: 3,428
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