Re: nested query problem

2018-09-06 Thread David Gauthier
Wow, I take that back. I thought there were many recs with "foo" but there wa sonly one. When I ran this against a value that actually had multiple records, it ran fine. Sorry for that. And Thanks for this query ! On Thu, Sep 6, 2018 at 5:15 PM David Gauthier wrote: > Not quite. This returns

Re: nested query problem

2018-09-06 Thread David Gauthier
Not quite. This returns one value. In the actual "sqf_runs" table, there are many records with user_id = 'foo'. I want one line for each where the fse.p-erl_sub_name and fse.end_datetime values are the latest values found in the flow_step_events_view view where the sqf_ids match. On Thu, Sep 6,

Re: nested query problem

2018-09-06 Thread Tom Lane
David Gauthier writes: > I'm having trouble with this query... > select sr.sqf_id, sr.status, fse.perl_sub_name, fse.end_datetime > from > sqf_runs sr, > (select perl_sub_name, end_datetime from flow_step_events_view where > sqf_id = sr.sqf_id order by 2 limit 1) fse > where sr.userid

Re: nested query problem

2018-09-06 Thread Paul Jungwirth
On 09/06/2018 01:59 PM, David Gauthier wrote: I'm having trouble with this query... select sr.sqf_id, sr.status, fse.perl_sub_name, fse.end_datetime   from     sqf_runs sr,     (select perl_sub_name, end_datetime from flow_step_events_view where sqf_id = sr.sqf_id order by 2 limit 1) fse