Does PostgreSQL have a pseudo-column like "LEVEL" in Oracle? -


does postgresql have pseudo-column "level" in oracle?
if not, how can create column similar "level"?

well, first of all, postgres not have hierarchical queries. no connect by, therefore no level.

you can similar things recursive cte , level column that's incremented every recursion.
query in oracle:

select employee_id, last_name, manager_id, level   employees connect prior employee_id = manager_id; 

.. translated recursive cte in postgres:

with recursive cte (    select employee_id, last_name, manager_id, 1 level      employees     union     select e.employee_id, e.last_name, e.manager_id, c.level + 1      cte c    join   employees e on e.manager_id = c.employee_id    ) select *   cte; 

Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -