Re: query, probably needs window functions

2020-05-23 Thread Scott Ribe
> On May 22, 2020, at 1:37 PM, Michael Lewis wrote: > > I believe something like this is what you want. You might be able to do it > without a sub-query by comparing the current name value to the lag value and > null it out if it's the same. > ... Thanks, that's what I needed! (And better than

Re: query, probably needs window functions

2020-05-22 Thread David G. Johnston
On Fri, May 22, 2020 at 12:38 PM Michael Lewis wrote: > I believe something like this is what you want. You might be able to do it > without a sub-query by comparing the current name value to the lag value > and null it out if it's the same. > This. I misread the question. You might also consi

Re: query, probably needs window functions

2020-05-22 Thread Michael Lewis
I believe something like this is what you want. You might be able to do it without a sub-query by comparing the current name value to the lag value and null it out if it's the same. select case when row_number = 1 then id end AS id, case when row_number = 1 then name end as name, phone.number from

Re: query, probably needs window functions

2020-05-22 Thread David G. Johnston
On Friday, May 22, 2020, Scott Ribe wrote: > given, let's say: > > create table person (id int not null, name varchar); > create table phone (id int not null, person_id int not null, number > varchar); > > select person.*, phone.number from person join phone on (person.id = > phone.person_id) ord

query, probably needs window functions

2020-05-22 Thread Scott Ribe
given, let's say: create table person (id int not null, name varchar); create table phone (id int not null, person_id int not null, number varchar); select person.*, phone.number from person join phone on (person.id = phone.person_id) order by... How would you get results where only the first