我想在一个查询中获得一篇帖子以及与该帖子相关的第一条评论.这是我在PostgreSQL中的表现:
SELECT p.post_id,
(select * from
(select comment_body from comments where post_id = p.post_id
order by created_date asc) where rownum=1
) the_first_comment
FROM posts p
Run Code Online (Sandbox Code Playgroud)
它工作正常.
但是,在Oracle中我收到错误ORA-00904 p.post_id:无效的标识符.
对于一个子选择似乎工作正常,但由于我需要使用rownum(在Oracle中没有限制/偏移),我无法仅使用一个注释.
我在这做错了什么?