Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to get consecutive pairs from a table in SQL?
"dean" <deanbrown3d_at_yahoo.com> a écrit dans le message de news: 1132174815.519465.282530_at_o13g2000cwo.googlegroups.com...
|I have a train's route table as follows (for one train):
|
| LOCATION_I varchar2(6) not null
| ORDERnumber not null
|
| The table lists all the stations that the train goes through.
|
| Is there a simple way to get consecutive pairs of these locations, if
| they are ordered by ROUTE_ORDER_I? I've done some SUM OVER queries, so
| was wondering if there was anything similar.
|
| Thanks,
|
| Dean
|
Have a look at LAG function:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions56a.htm#83619
Regards
Michel Cadot
Received on Wed Nov 16 2005 - 15:19:51 CST