Re: Puzzline CROSS JOIN when doing RECURSIVE CTE

2022-04-18 Thread Alban Hertroys
> On 18 Apr 2022, at 14:51, Pól Ua Laoínecháin wrote: > > Hi Alban, and many thanks for your input. > >> My first question is why you’re using a recursive CTE here? This doesn’t >> appear to be hierarchical data (such as a tree), unless perhaps you intended >>

Re: Puzzline CROSS JOIN when doing RECURSIVE CTE

2022-04-18 Thread Pól Ua Laoínecháin
Hi Alban, and many thanks for your input. > My first question is why you’re using a recursive CTE here? This doesn’t > appear to be hierarchical data (such as a tree), unless perhaps you intended > to actually traverse the HTML document hierarchy? This is basically an exercise on my p

Re: Puzzline CROSS JOIN when doing RECURSIVE CTE

2022-04-18 Thread Alban Hertroys
> On 18 Apr 2022, at 11:56, Pól Ua Laoínecháin wrote: (…) > All of the code below is available on the fiddle here: > > https://dbfiddle.uk/?rdbms=postgres_13&fiddle=0cc20c9081867131260e6e3550bd08ab (…) > OK, grand, now I wish to perform a RECURSIVE CTE on it. So,

Puzzline CROSS JOIN when doing RECURSIVE CTE

2022-04-18 Thread Pól Ua Laoínecháin
Hi all, I've been working on a recursive query (I've already written a few, so I'm not a complete newbie.. All of the code below is available on the fiddle here: https://dbfiddle.uk/?rdbms=postgres_13&fiddle=0cc20c9081867131260e6e3550bd08ab I have a table called line SELECT idx, length, s

Re: Recursive CTE

2018-12-30 Thread Andy Colson
On 12/29/18 12:34 PM, Glenn Schultz wrote: All, Following my earlier post on variable instantiation, I rethought how I was working with dates and realized I can fix the date and use static interval.  I came up with this recursive CTE which is the end goal.  However, the problem is that the

Recursive CTE

2018-12-29 Thread Glenn Schultz
All, Following my earlier post on variable instantiation, I rethought how I was working with dates and realized I can fix the date and use static interval. I came up with this recursive CTE which is the end goal. However, the problem is that the convexity query cannot be used as a subquery. So I

Re: Recursive CTE for building menus

2018-04-13 Thread Tim Smith
On 13 April 2018 at 16:04, Paul Jungwirth wrote: > On 04/13/2018 02:09 AM, Bob Jones wrote: >> >> The adaptions I am trying to make are as follows: >> - Higher priority moves the item higher up the menu (i.e. adapting >> from the original "votes" concept). >> - Default alphabetical ordering of tit

Re: Recursive CTE for building menus

2018-04-13 Thread Paul Jungwirth
i, I wrote that blog post! :-) This works for me: WITH RECURSIVE cte (menu_item_id, menu_title, path, menu_parent, depth, menu_priority) AS ( SELECT menu_item_id, menu_title, ARRAY[(-menu_priority, menu_title, menu_item_id)] AS path, menu_parent,

Recursive CTE for building menus

2018-04-13 Thread Bob Jones
Hello, Whilst researching current thinking on hierarchical queries in Postgres, I stumbled accross this excellent blog post: https://illuminatedcomputing.com/posts/2014/09/postgres-cte-for-threaded-comments/ But try as I might, my SQL-foo is not up to scratch to adapt it to my needs, I keep on l