0
我試圖在Ruby on Rails中查找表中特定SongId的最頻繁標題。這是我到目前爲止有:Rails/SQL:如何找到特定ID上最頻繁的列值
SongDetail.where(song_id: id).group('title').order('COUNT(*) DESC').first[:title]
我不斷收到讀取錯誤:
PG::GroupingError: ERROR: column "song_details.id" must appear in the GROUP BY clause or be used in an aggregate function
應該如何進行?
也做到了,謝謝! – dcporter7
歡迎@ dcporter7 – ashvin