Fixed bug that alias does not exist for inner sub-query, the condition should have been added on the outside.