I have 3 columns (id, start and end) in TSQL
ID; Start; END 1; 1; 5; 2; 10; 15; Then it will generate such a number:
1, 1 1, 2 1, 3 1, 4 1, 5 2, 10 2, 11 2, 12 2, 13 2, 14 2, 15 Again I can imagine that there is a cursor but there is no better way?
A CTE approach is easy
with tab (id 1 Select as, 1 in the form of start, 2, 10, 15), whistle (select ID, start, select all the union from tab, start id, start with whistle, starting from + 1 & Lt; = en) Choose ID, start with CTE command by id
Comments
Post a Comment