0
我想基于列是唯一在那里我得到记录运行轨道的查询,在这种情况下,“ACCOUNT_ID”SELECT DISTINCT ON表达式必须初始ORDER BY表达式匹配
这完美的作品:
@comments = @store.comments.where(account_id: @selected_array).where(flagged: true).select('distinct on (account_id) *').paginate(:page => params[:page], :per_page => 30)
除订单关闭外。当我试图通过创建日期订购:
@comments = @store.comments.where(account_id: @selected_array).where(flagged: true).select('distinct on (account_id) *').order("created_at DESC").paginate(:page => params[:page], :per_page => 30)
我得到的错误:
PG::InvalidColumnReference: ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions
如何让不同的部分,同时通过创建时间排序仍然有效?