我想运行这个查询:
SELECT DISTINCT ON (address_id) purchases.address_id, purchases.*
FROM purchases
WHERE purchases.product_id = 1
ORDER BY purchases.purchased_at DESC
但是我得到了这个错误:
SELECT DISTINCT ON表达式必须匹配表达式的初始顺序
添加address_id
作为第一个ORDER BY
表达式可以消除错误,但我真的不想在address_id
上添加排序。是否可以不通过address_id
进行排序?