[DB] fixed: error in queries containing apexes