table dependency checking work with sub query