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 -> Re: Getting succeeding and preceeding records

Re: Getting succeeding and preceeding records

From: Rüdiger J. Schulz <johannes.schulz_at_web.de>
Date: 14 Nov 2001 11:39:42 +0200
Message-ID: <3bf249ee$3@netnews.web.de>


I dont know exactly what you want, so I try to give two possible solutions:

  1. generally select over all data of your table:

   create or replace view recsta_view
   as

      select rownum lineno, invno 
      from fms0001.recsta;


   now you (or your application) can select:    

      select * from recsta_view 
         where lineno beteen 1 and 10;
      select * from recsta_view 
         where lineno beteen 11 and 20;
      ...


2. select with (fixed) search-criteria:

   create or replace view recsta_view
   as

      select rownum lineno, invno 
      from fms0001.recsta
      where invno like '12345%';


   now you (or your application) can select:    (here you get only invnos' with '12345%'...)    

      select * from recsta_view 
         where lineno beteen 1 and 10;
      select * from recsta_view 
         where lineno beteen 11 and 20;
      ...


hth
Rüdiger J. Schulz
rjs_at_berlin.de

j_gippert_at_yahoo.com (jgippert) wrote:
>Hello everybody!
>
>I´ve got a problem doing an SQL request to our Oracle 8i server. I´d
>like to do a SELECT statement, which gives me the result and the next
>10 succeeding records. So I used the following stament:
>
>select invno from fms0001.recsta where invno like '12345%' and
>rownum<=10
>
>This gives me the first 10 (in this particular case) invoices-no.
>which start with '12345'. Now, our customer also wants to see the 10
>invoice numbers that come *before* the searched number. I already
>tried something like ".. rownum -10" but that doesn´t seem to work. Is
>there a SQL-statement that does this job or do I have to make a
>pre-select on all records and then programm our software to do the
>rest of the work?
>
>Any help on this would be very appreciated!!
>
>Thanks in advance!
>
>Bye,
>Joerg!

-- 
__________________________________________________________
News suchen, lesen, schreiben mit http://newsgroups.web.de
Received on Wed Nov 14 2001 - 03:39:42 CST

Original text of this message

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