add missing application_flag column to subquery