So, I am playing with some SQL Code.
Let's say we have a SQL Table (Start (int), End (int)) with the following data:
I want to be able to get the following result:
I am sure there are better ways of doing this but this is what I can think of and it almost works:
WITH x AS ( SELECT ROW_NUMBER() OVER (ORDER BY Start ASC) AS StartRowNumber, Start FROM Numbers ) SELECT * FROM x WHERE StartRowNumber % 2 = 1 ORDER BY Start; WITH x AS ( SELECT ROW_NUMBER() OVER (ORDER BY [End] ASC) AS RowNumber, [End] FROM Numbers ) SELECT * FROM x WHERE RowNumber % 2 = 0 ORDER BY [End];
What I want to do now is some how merge the rows in that the results from the 2nd CTE are put into the columns into the first CTE or write some query that merges the results together displaying x and then x2 next to each other.