Re: Subquery to select max(date) value

Поиск
Список
Период
Сортировка
От Rich Shepard
Тема Re: Subquery to select max(date) value
Дата
Msg-id alpine.LNX.2.20.1902151230581.31662@salmo.appl-ecosys.com
обсуждение исходный текст
Ответ на Re: Subquery to select max(date) value  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Ответы Re: Subquery to select max(date) value  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-general
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


В списке pgsql-general по дате отправления:

Предыдущее
От: Andre Piwoni
Дата:
Сообщение: Re: Promoted slave tries to archive previously archived WAL file
Следующее
От: Hugh Ranalli
Дата:
Сообщение: Channel binding not supported using scram-sha-256 passwords