Unknown column 'Agency' in 'having clause'