简体   繁体   中英

SQL previous next row

i have a table 1 with all record :

Id, Arrival,Departure, Datestamp (Datestamp is unique)
1 LG LE 2011-11-12 12:30:57
2 LE LG 2010-11-12 12:30:51
3 LE LG 2019-10-12 12:30:36
4 LG LE 2009-09-12 12:20:45
5 LP LA 2008-11-12 11:30:25
6 LP LA 2007-07-12 12:40:56
7 LA LP 2005-03-12 12:55:51
8 LG LP 2001-11-12 12:22:25

i want select all record whith Départure from row = Arrival from prévious row order by datestamp DESC

Example :

1 LG LE 2011-11-12 12:30:57
3 LE LG 2019-10-12 12:30:36
4 LG LE 2009-09-12 12:20:45
6 LP LA 2007-07-12 12:40:56
7 LA LP 2005-03-12 12:55:51

select a.Arrival,a.Departure, a.Date from table1 a inner join table2 b on a.Arrival=b.OArrival and a.Departure1=ODeparture1

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM