>Hi All,
>
>I have two tables which are identical in all respects; number of records, fields per record, and even the value of all fields except for the value of a particular datatime field. The records contain user access info, one record per user, and the datetime field contains the last access datetime.
>
>I need to extract from these two files the latest record only for each user. So either the record from file1 or from file2, whichever has the latest datetime access.
>
>I can obviously code this easily enough but was wondering if there was an easy one-liner SELECT statement or some such?
>
>Thanks,
At the risk of looking foolish (again)
If I read this correctly, the tables are 100% identical except for the datetime field???
If so it doesn't matter which table the record comes from (since they're identical). You just need to get a record and the latest timestamp. How about
SELECT f.*,IIF(f.datetime>=s.datetime,f.datetime,s.datetime) as last_date FROM first f, second s;
WHERE f.primarykey = s.primarykey