2017-09-14 24 views
-2

让我们说我有改写红宝石活动记录sql语句

class KdpReport < ActiveRecord::Base 
end 

如何翻译使用的活动记录模型红宝石这个sql语句?

SELECT DISTINCT 
     `kdp_reports`.`date` AS `date`, 
     `kdp_reports`.`book_title` AS `book_title`, 
     `kdp_reports`.`marketplace` AS `marketplace` 
FROM 
    `kdp_reports` 

我用红宝石 “2.4.0” 和活动记录宝石没有护栏

我只能想到这样的事情:

KdpReport.select(:date).distinct.select(:book_title).distinct.select(:marketplace).distinct 
+0

你提出的解决方案不正是你'要求。什么是问题?请停止在StackOverflow上运行shitposting。 – coreyward

回答