[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

[sqr-users] RE: Using parenthesis in a dynamic where cond.



"And" takes precedence over "or"; in other words, if there are no
parentheses, "and" will get executed first.

So the one that doesn't need parentheses is "where (a and b) or (c and
d)".  "where a and b or c and d" will produce the same result.

If you leave the parentheses out of "where (a or b) and (c or d)", you
would end up with the equivalent of "where a or (b and c) or d", which
is not what you want, so you need parentheses in this case.

Just imagine that there are invisible parentheses around every "and"
clause and you will be all set!  To make up a rule that's easy to
remember, you could also keep in mind that "and" is alphabetically
before "or", so it comes first.

Denise M. White
EBS Programmer/Analyst III
Dynamics Research Corporation
------------------------------

Message: 3
Date: Tue, 2 Aug 2005 08:51:55 -0700 
From: "Alexander, Steve" <Steven.Alexander@sanjoseca.gov>
Subject: RE: [sqr-users] Using parenthesis in a dynamic where cond.
To: "'This list is for discussion about the SQR database
        reportinglanguage       from Hyperion Solutions.'"
<sqr-users@sqrug.org>
Message-ID:
        
<62AFC819CCF3D611827A00065B3F798106BA8CF7@sj-exchange.ci.sj.ca.us>
Content-Type: text/plain;       charset=iso-8859-1

In your example you don't need parentheses.  Generally, you only need
them
when you're combining "and" and "or":

where (a and b) or (c and d)
where (a or b) and (c or d)

Even here, the precedence between "and" and "or" makes the parentheses
unnecessary in one of these cases, but I can never remember which one,
so I
use them anyway.

If you really want to use parentheses here, go ahead.  Put them in the
literal like any other character:

LET $DATE_RANGE = 'and (A.SHIP_DATE  <=  '''|| $ToDate || '''' || ' AND
A.SHIP_DATE >=  '''|| $FromDate ||''')'

-----Original Message-----
From: Gowri Srinivas [mailto:gow_srinivas@yahoo.com]
Sent: Tuesday, August 02, 2005 7:46 AM
To: sqr-users@sqrug.org
Subject: [sqr-users] Using parenthesis in a dynamic where cond.


Can anybody tell me how to generate a dynamic where condition in which I
need to incorporate parenthesis between AND statements? Here's the
condition
without the parenthesis:
LET $DATE_RANGE = 'and A.SHIP_DATE  <=  '''|| $ToDate || '''' || ' AND
A.SHIP_DATE >=  '''|| $FromDate ||'''' 
 
THis should look like 

select * from ps_zsc_ld_seq A 
where (A.SHIP_DATE >= '01-AUG-05' and A.ADD_DTTM >= '01-AUG-05')
AND (A.SHIP_DATE <= '31-AUG-05' and A.ADD_DTTM <= '31-AUG-05')

Thanks very much.



_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users