on-internet
← Community

DuckDB support for Postgres function WITH ORDINALITY

Stack Overflow ·

Currently i'm using DuckDB to execute the following Postgres query containing WITH ORDINALITY function on a polars dataframe: with suffixes as ( select ordrnbr,(nr-1)/2 N ,max(case when nr%2=1 then elem end) Nkey ,cast(max(case when nr%2=0 then elem end) as int) Nval from test t left join lateral unnest(string_to_array(t.description, '@')) WITH ORDINALITY AS a(elem, nr) ON true group by ordrnbr,(nr-1)/2 ) select concat(t.ordrnbr,'-',row_number()over(partition by t.ordrnbr order by s.N))ordrnbr , vehiclename, description, id, totprice ,coalesce(s.Nval,totprice) ind_price from test t left join s

Comments

Sign in or sign up to comment and upvote.

No comments yet.