Page 1 of 1

Select next row from the table

PostPosted: Fri Oct 31, 2008 8:11 pm
by Namrata Kalghatgi
Hi,

I have a requirement in which i want to select a row and the next row of the row which satisfies a particular condition.

For example

Table 1:

Col1 Col2 Col3 Col4
----------------------------------------
Row1 1 abc 11 xyz
Row2 2 def 22 uvw
Row3 3 ghi 11 rst
Row4 4 jkl 33 opq

Now my requirement is to select Row2 and Row1 when Row1 satisfies the condition, or Select Row2 and Row3 when Row2 satisfies the condition.

In case the the query is

Select * From table 1 where C0l3 = 11;

The i shud select Row1 and Row2 and also Row3 and Row4.

Can anyone tell me a query for this.

Is there any way other than using a cursor?

Re: Select next row from the table

PostPosted: Sat Nov 01, 2008 1:12 am
by dick scherrer
Hello,

You should use a cursor.