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

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



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.


                
---------------------------------
 Start your day with Yahoo! - make it your home page 

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

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