开发说pg中执行sql报错,发来消息让帮看看:



SELECT DISTINCT ON expressions must match initial ORDER BY expressions


  

详细语句如下:



SELECT DISTINCT ON
( p_no ) p_no,
p_name,
p_manager,
p_manager_no,
p_dept
FROM
P
WHERE
corporation = $1
AND status = $2
ORDER BY
create_time DESC


  

失败的原因看看官方文档就知道了:

SELECT DISTINCT ON expressions must match initial ORDER BY expressions_分享