Given the following: select * from tmp_addresses [x] where rowid in ( select rowid from tmp_addresses [a] where a.version_id = '0060' and [a].zip = [x].zip and [a].crrt = [x].crrt limit ( SELECT net_non_pieces FROM crrt_net_non [b] WHERE [b].zip = [x].zip AND [b].crrt = [x].crrt ) )
The above sql fails parsing because of the alias [x] usage in the limit clause. If I eliminate the [x] alias from the limit, i.e. "WHERE [b].zip = zip AND [b].crrt = crrt", then the sql parses and executes. Note the performance: [2015-10-16 13:49:37] completed in 2m 30s 730ms. I'm curious as to why the alias is not accessible from the limit sub-query?