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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 One record over

Author  Topic 

ERAN185
Starting Member

1 Post

Posted - 2013-03-16 : 18:47:28
Hi
I have a table that has 2 columns - ID, Name
I did a query and the result is records that their ID: 3,8,11,14, etc.
What is the simplest way to get the records that are in one line above - - 4,9,12,15 etc.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-16 : 21:23:00
[code]SELECT a.ID, a.Name FROM
YourTableHere AS a
INNER JOIN (YourQueryHere) AS b
ON a.ID = b.ID+1;[/code]This treats your query as a blackbox. It can be simpler; if you post your query, we could suggest how it could be made simpler if possible.
Go to Top of Page
   

- Advertisement -