I need to get a list of locations ordered by the number of picture that I have in the DB for these locations, here is my query
Location.select(:city).group(:city).order("SUM(images_count) DESC").sum(:images_count)
This worked like a charm, unfortunately, I now need to add province and country to prevent ambiguities to arise, so I now have this
Location.select(:city, :province, :country).group(:city, :province, :country).order("SUM(images_count) DESC").sum(:images_count)
And this is not working :(
Could someone help me out with this query?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…