【发布时间】:2009-08-24 11:27:32
【问题描述】:
我想进行查询,以便只能获取至少有 50 个地点的位置。
我有一张位置表:
Id, City, Country
1, Austin, USA
2, Paris, France
还有一个按 Location_id 连接到 Locations 的 Places 表
Id, Name, Details, Location_id
1, The Zoo, blah, 2
2, Big Park, blah, 2
我可以像这样加入他们:
选择places.name、places.id、locations.country、locations.city 从地方 INNER JOIN 位置 ON places.location_id = locations.id
如何才能仅获得至少有 50 个地点的城市的结果并按最大数量排序?
谢谢!
【问题讨论】:
标签: sql mysql ruby-on-rails count aggregate