Re: nextval per counted

2023-01-27 Thread Rob Sargent
On 1/27/23 14:31, David G. Johnston wrote: On Fri, Jan 27, 2023 at 2:25 PM Rob Sargent wrote: On 1/27/23 14:20, David G. Johnston wrote: On Fri, Jan 27, 2023 at 1:59 PM Rob Sargent wrote: I'm trying to craft SQL to invoke a sequence nextval once per grouped value.

Re: nextval per counted

2023-01-27 Thread David G. Johnston
On Fri, Jan 27, 2023 at 2:25 PM Rob Sargent wrote: > On 1/27/23 14:20, David G. Johnston wrote: > > On Fri, Jan 27, 2023 at 1:59 PM Rob Sargent wrote: > >> I'm trying to craft SQL to invoke a sequence nextval once per grouped >> value. >> >> > This seems like a very unusual usage of nextval/sequ

Re: nextval per counted

2023-01-27 Thread Rob Sargent
On 1/27/23 14:20, David G. Johnston wrote: On Fri, Jan 27, 2023 at 1:59 PM Rob Sargent wrote: I'm trying to craft SQL to invoke a sequence nextval once per grouped value. This seems like a very unusual usage of nextval/sequences... with cleanup as (   select DISTINCT e.ma

Re: nextval per counted

2023-01-27 Thread David G. Johnston
On Fri, Jan 27, 2023 at 1:59 PM Rob Sargent wrote: > I'm trying to craft SQL to invoke a sequence nextval once per grouped > value. > > This seems like a very unusual usage of nextval/sequences... with cleanup as ( select DISTINCT e.ma, coalesce(e.pa, 'fix') as pa from ... ), compute as ( se

nextval per counted

2023-01-27 Thread Rob Sargent
I'm trying to craft SQL to invoke a sequence nextval once per grouped value. So far I have this: with husb as( select e.ma, count(distinct coalesce(e.pa, nextval('egogen')::text)) as mates from emp_all_by3 e group by e.ma order by mates ) select mates, count(*) from husb