帮助我在ruby中编写GROUP_BY条件。我现在必须将PHP项目迁移到Ruby,并面临这个问题。不要严格判断,我是Ruby的新手。
这是php中的查询:
$get_details_email = db_query("Select secret_key,trustee_status,email_id from trustees where request_by='email' AND user_id='$user_id' group by email_id");
如何将下面的查询分组到email_id?
get_details_email = Trustee.select(:secret_key, :trustee_status, :email_id).where(:request_by => 'email', :user_id => user_id)
答案 0 :(得分:4)
get_details_email = Trustee.select(:secret_key, :trustee_status, :email_id).where(:request_by => 'email', :user_id => user_id).group(:email_id)