Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

A sort of unpivot

$
0
0

Hi guys, I got this issue that I'm trying to resolve:

having

CREATE TABLE #TRY (idfcl int identity,
, fcl int, datatry datetime, start int, endtry int, rate int)
insert into #try values (20,01-01-2014,1,5, 0.6),
(20,01-01-2014,6,12, 0.63),(20,02-01-2014,4,7, 0.81),
(20,02-01-2014,10,16, 0.76),(26,01-01-2014,22,24, 0.11)

I need to create a verticality that take the data from start to endtry. That means

20 01-01-2014  1 0.6

20 01-01-2014  2 0.6

20 01-01-2014  3 0.6

20 01-01-2014  4 0.6

20 01-01-2014  5 0.6

20 01-01-2014  6 0.63

20 01-01-2014  7 0.63

Pratically, taking the first row, I need to read the start ( in this case 1) and the endtry ( 5) in a vertical way , keeping of course the date and the coefficient (datatry and rate) 

Any suggestion? Thank you



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>