Questions tagged «distinct-on»

6
PostgreSQL使用不同的ORDER BY打开
我想运行此查询: SELECT DISTINCT ON (address_id) purchases.address_id, purchases.* FROM purchases WHERE purchases.product_id = 1 ORDER BY purchases.purchased_at DESC 但是我得到这个错误: PG ::错误:错误:SELECT DISTINCT ON表达式必须匹配初始ORDER BY表达式 添加address_id为第一个ORDER BY表达式可以使错误消失,但是我真的不想添加sorting over address_id。是否可以不按顺序进行address_id?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.