tags:

views:

25

answers:

0

I need to know the team with highest number of matches in a certain city.

SELECT COUNT(am_matches.team_id) AS matches_count,
am_matches.team_id AS team_id
FROM am_matches
LEFT JOIN am_team ON (am_matches.team_id = am_teams.id)
WHERE am_matches.status = '3' AND am_teams.city_id = '$city_id'
GROUP BY am_matches.team_id
ORDER BY COUNT(am_matches.team_id) DESC LIMIT 1

This works on a local server (wamp), but on a shared host throws "Invalid use of group function". Is there another way of getting this? I need to make a lot of similar querys so I would like to know a more readable approach of getting similar values. Thanks.