2011-04-22 74 views
0

我試圖用活動記錄計算具有不同列的行數。計算具有不同列的行數

下面的SQL作品並給我正確的結果:

SELECT COUNT(DISTINCT(user_id)) FROM attempts WHERE score = 100 AND problem_id = 1 

但這代碼引發ActiveRecord::StatementInvalid錯誤:

attempts.where(:score => 100).count(:distinct => :user_id) 

回答