Unknown column 'TrailType' in 'having clause'