SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 One record over
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ERAN185
Starting Member

1 Posts

Posted - 03/16/2013 :  18:47:28  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3588 Posts

Posted - 03/16/2013 :  21:23:00  Show Profile  Reply with Quote
SELECT a.ID, a.Name FROM
YourTableHere AS a
INNER JOIN (YourQueryHere) AS b 
	ON a.ID = b.ID+1;
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000