Re: Problem with LATERAL

2022-10-13 Thread Julien Rouhaud
On Thu, Oct 13, 2022 at 08:04:03AM +, Eagna wrote: > > > > ERROR: syntax error at or near "WHERE" > > > LINE 10: WHERE o.total_price > ISNULL(sub.paid, 0); > > > > There error here is because a JOIN clause requires a join condition. Adding > > an > > "ON true" is probably what you want. You wo

Re: Problem with LATERAL

2022-10-13 Thread Eagna
> > ERROR: syntax error at or near "WHERE" > > LINE 10: WHERE o.total_price > ISNULL(sub.paid, 0); > There error here is because a JOIN clause requires a join condition. Adding an > "ON true" is probably what you want. You would also need to change isnull() > with coalesce(). > The final que

Re: Problem with LATERAL

2022-10-13 Thread Julien Rouhaud
Hi, On Thu, Oct 13, 2022 at 07:05:48AM +, Eagna wrote: > > relatively simple one would have thought! I tried to convert this into a > Postgres query as follows: > > SELECT  o.order_id, >   o.total_price - COALESCE(sub.paid, 0) > FROM _order o > LEFT JOIN LATERAL ( >     SELECT SUM(p.amount) A

Problem with LATERAL

2022-10-13 Thread Eagna
Good Morning all, I am having a problem understanding a simple LATERAL join - I'm working on grasping them. All tables and data are at the bottom of this question and on the fiddles, SQL Server (working) and Postgres (not working). SQL Server fiddle - https://dbfiddle.uk/hjBBd87B Postgres