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 |
|
njahnavi
Starting Member
4 Posts |
Posted - 2009-03-16 : 12:15:43
|
| I have data like thisJObNO 1245369I want to write a query like this which gives the jobno and also the difference between the jobno and the next greatest jobnoJObNO Difference1 12 14 15 13 16 39 0Any ideas..Any help is greatly appreciated. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 12:31:19
|
| [code]SELECT t.JobNo,COALESCE((SELECT TOP 1 JobNo FROM Table WHERE JobNo > t.JobNo ORDER BY JobNo),0)- t.JobNoFROM Table t[/code] |
 |
|
|
njahnavi
Starting Member
4 Posts |
Posted - 2009-03-16 : 13:09:25
|
| HI Visakh16Thanks for the reply.It solved the issue. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 13:11:39
|
| welcome |
 |
|
|
|
|
|