Fix query to cater for branch code filter