I want to convert below mentioned oracle hierarchical query to postgresql
SELECT catalog_id, sub_tree_id
FROM my_catalog
CONNECT BY PRIOR catalog_id = sub_tree_id;
I have tried using the following postgresql query but not getting the expected result
WITH RECURSIVE q AS (
SELECT po.catalog_id,po.sub_tree_id
FROM my_catalog po
UNION ALL
SELECT po.catalog_id,po.sub_tree_id
FROM my_catalog po
JOIN q ON q.catalog_id=po.sub_tree_id
)
SELECT * FROM q;
ORACLE OUTPUT(EXPECTED RESULT)
POSTGRESQL OUTPUT(ACTUAL RESULT)


create tableandinsertstatements for PostgreSQL (at the very least) to reproduce your problem. From your images, it doesn't even look like Oracle and PostgreSQL have the same data. If they don't have the same data, different results are inevitable.order byclause is used, see: en.wikipedia.org/wiki/Result_set. Because of this you don't see the same few rows at the top of both resultses.