Re: Operator Precedence problem?

From: Jesus Aneiros <aneiros(at)jagua(dot)cfg(dot)sld(dot)cu>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: Operator Precedence problem?
Date: 2000-08-12 20:57:56
Message-ID: Pine.LNX.4.10.10008121656570.22653-100000@jagua.cfg.sld.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The ANSI/ISO standard specifies that NOT has the highest priority, then
AND and finally OR.

--
Jesus Aneiros Sosa
mailto:aneiros(at)jagua(dot)cfg(dot)sld(dot)cu
http://jagua.cfg.sld.cu/~aneiros

On Sat, 12 Aug 2000, Philip Warner wrote:

>
> I have a peculiar problem that I can't reproduce on a trivial database:
>
> select product, priority, count(*) as completed from issue
> where
> product = 'DIS'
> and create_date < '1-Aug-2000' and finish_date >= '1-Aug-2000' or
> finish_date is null
> group by product, priority;
>
> This produces a list of all products - not just 'DIS'. If I put the last
> two clauses in parnthesis, then it works as expected:
>
> select product, priority, count(*) as completed from issue
> where
> product = 'DIS'
> and create_date < '1-Aug-2000' and (finish_date >= '1-Aug-2000' or
> finish_date is null)
> group by product, priority;
>
> Which makes me think that the precedence of 'or' is not what I expected. Is
> this a feature? If so, the fact that I get precisely the opposite behaviour
> in simple test databases must be a bug, I think.
>
> Any help or explanation would be appreciated...
>
>
>
> ----------------------------------------------------------------
> Philip Warner | __---_____
> Albatross Consulting Pty. Ltd. |----/ - \
> (A.B.N. 75 008 659 498) | /(@) ______---_
> Tel: (+61) 0500 83 82 81 | _________ \
> Fax: (+61) 0500 83 82 82 | ___________ |
> Http://www.rhyme.com.au | / \|
> | --________--
> PGP key available upon request, | /
> and from pgp5.ai.mit.edu:11371 |/
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Web Manager 2000-08-14 14:02:55 select an entry with a NULL date field
Previous Message Tom Lane 2000-08-12 15:56:30 Re: Operator Precedence problem?