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, November 24, 2014 7:37 AM
Points: 228, Visits: 568
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
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:33 AM
Points: 856, Visits: 1,506
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


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 1:37 AM
Points: 997, Visits: 3,089
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