On Wed, 13 Feb 2019, Andrew Gierth wrote:
You want LATERAL.
Andrew, et al,:
I found a couple of web pages describing the lateral join yet have not
correctly applied them. The manual's page did not help me get the correct
syntax, either. Think I'm close, however:
select p.person_id, p.lname, p.fname, p.direct_phone, o.org_name, a.next_contact
from people as p, organizations as o
lateral
(select a.next_contact
from activities as a
where a.next_contact is not null and a.next_contact <= 'today' and
a.next_contact > '2018-12-31'
order by person_id,next_contact);
When run I get this syntax error:
$ psql -f get_next_contact_dates.sql -d bustrac
psql:get_next_contact_dates.sql:10: ERROR: syntax error at or near "lateral"
LINE 3: lateral
What am I still missing?
Regards,
Rich