I'm developing on MySQL and have deployed to Heroku which is using Postgres. It seems some of my queries will need rewriting to work with Postgres. Can anyone assist with fixing my group by issues such as the below please?
Heroku Log error:
ActiveRecord::StatementInvalid (PGError: ERROR: column "itunes_data.artist_show" must appear in the GROUP BY clause or be used in an aggregate function
From my controller:
def itunes_top_tracks
@itunes_top_tracks = ItunesData.all(:select => "artist_show, title, label_studio_network, isrc, SUM(units) as unitsum", :group => :isrc, :order => "unitsum DESC", :limit => 10)
end
I understand what the problem is and know how i'd do this in straight SQL, i'm just not sure of the Rails way?
Thanks all