I've seen queries similar to

select d.(stuff) from a, b, c, d
where a.(stuff) = b.(stuff) and b.(stuff) = c.(stuff) and c.(stuff) = d.(stuff)

and have seen query "optimizers" make stupid decisions about what to select from where and when. This is particularly evident when you upgrade from one version of a database to another; often times they've "improved" the optimizer enough to shoot the hell out of your carefully crafted queries that worked with the old one.

(Most databases seem to have pathetic query analyzers and diagnostics, but I digress.)

Not that this helps in this particular problem. I ran into a report converting tool ("automatically" converted from one 4GL with one flavor of database selection syntax to another) that did some Gawdawful stuff to the SQL, but because there were so many reports it wasn't possible to go through and optimize each report. I have every reason to think that those reports (in the tortured SQL version) still exist.