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

how to update the order from 1 to .... based on start order and end order?

$
0
0

Hello All,

I have below table/data structure,

DECLARE @TBL TABLE (START_ORD INT, END_ORD INT, ENTITY_NAME VARCHAR(10), ENTITY_ORDER INT)
INSERT INTO @TBL VALUES
(1, 0, 'ABC', 5), 
(1, 1, 'ABC1', 8),
(1, 2, 'ABC2', 8),
(3, 0, 'ABC3', 0),
(4, 1, 'ABC4', 1)
SELECT * FROM @TBL

1. start order starts with 1 to .....

2. end order starts with 0 to .....

3. having different combination of start order & end Order (1 - 0, 1 - 1, 1 - 2, 3 - 0, 4 - 1, etc), hence order for,

1 - 0 should be 1

1 - 1 should be 2

1 - 2 should be 3, etc.....

I'm looking for below output, please suggest, Thanks!


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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