Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> retreiving the "next" record using SQL

retreiving the "next" record using SQL

From: ORcastillo <orcastillo_at_aol.com>
Date: 22 Oct 1998 14:33:35 GMT
Message-ID: <19981022103335.14168.00003329@ng89.aol.com>


I'm new to SQL and have the following question: I have a table whose primary key is a combination of 2 columns and the data types are "number + alpha string". We need to do a "next" operation but I don't seem to find something explicit in SQL for such a thing. I tried doing

select * from tablename
where column1 >= presetvalue

      and 
      column2 >= 'presetvalue'

order by column1, column2

Well, it fails because if the "next" record's col2 may be alphabetically less than what the sql statement is asking for. Ex. find the next record after col1= 1, col2 = '00804008'

    the next record is col1= 2, col2 = '000' based on the above sql statement the real next record doesn't meet the criteria, so we get something else
I'm sure this is a common ocurrence! Received on Thu Oct 22 1998 - 09:33:35 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US