SQLite Forum

Join tables by nearest older date
Login
You could also do something like this:

```
select *
  from WinEvents
  join GameEvents
    on GameID = (
                   select GameID
                     from GameEvents
                    where GameDate <= WinDate
                 order by GameDate desc
                    limit 1
                )
;
```

Note that they are all really pretty much the same thing.  They all use a correlated subquery to find the appropriate GameID which basically means that subquery is run for each row of the result.