[thelist] SQL trouble
Anthony Baratta
anthony at baratta.com
Wed Nov 16 18:50:08 CST 2011
I'm concerned that the SQL is not working correctly, if the "catch-all"
is not returning the latest status for each batch.
I have a better idea:
select batches.id, batches.uniq, history.status from batches
join (select max(id) as history_id, batch_id from history group by
batch_id) as history_max
on batches.id = history_max.batch_id
join history on history.id = history_max.history_id
--
Anthony Baratta
Forgiveness does not change the past, but it does enlarge the future
-- Paul Bose
More information about the thelist
mailing list