Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rohitdev2k12
Starting Member
3 Posts |
Posted - 2014-11-25 : 01:40:00
|
id number1 22 4 3 64 10o/p should benumber261016 |
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2014-11-25 : 06:41:34
|
[code]-- *** Test Data ***CREATE TABLE #t( id int NOT NULL ,number int NOT NULL);INSERT INTO #tSELECT 1, 2UNION ALL SELECT 2, 4UNION ALL SELECT 3, 6UNION ALL SELECT 4, 10;-- *** End Test Data ***SELECT T1.number + COALESCE(T2.number, 0) AS ResultFROM #t T1 LEFT JOIN #t T2 ON T1.id = T2.id + 1;[/code] |
|
|
|
|
|