D
david epsom dot com dot au
I need a query to return linked newdate, oldate from a table of date
records.
Table like this:
1 2000-3-1
1 2000-4-1
2 2000-3-1
2 2000-4-1
Result like this:
1 2000-3-1 [null]
1 2000-4-1 2000-3-1
2 2000-3-1 [null]
2 2000-4-1 2000-3-1
I'm thinking, something like:
select mytable.mydate as newdate, oldate
from mytable join (select max mydate as oldate
from mytable as q where q.mydate < mytable.mydate)
Has anyone got a worked example of the syntax?
records.
Table like this:
1 2000-3-1
1 2000-4-1
2 2000-3-1
2 2000-4-1
Result like this:
1 2000-3-1 [null]
1 2000-4-1 2000-3-1
2 2000-3-1 [null]
2 2000-4-1 2000-3-1
I'm thinking, something like:
select mytable.mydate as newdate, oldate
from mytable join (select max mydate as oldate
from mytable as q where q.mydate < mytable.mydate)
Has anyone got a worked example of the syntax?