Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Common Table Expressions WITH RECURSIVE Trees In The Database - Advanced data structures

195,069 views

Published on

Common Table Expressions
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree,
emp || ‘.’ AS path
FROM emp_orgchart
WHERE boss IS NULL
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
E2.path || E1.emp || ‘.’ AS path
FROM emp_orgchart
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY path;
54

Published in: Technology, Business
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website! https://vk.cc/818RFv
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Thank you for this
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hi Lorenzo, could you take a look of this link in which I design some new solutions: https://github.com/drinkjava2/Multiple-Columns-Tree , with 2 fields (sorted) "line" and "level" and a end tag, will easy do query/add/delete operation.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • please make this downloadable
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

×