dbTalk Databases Forums  

Using an IF function in a WHERE clause

comp.databases.btrieve comp.databases.btrieve


Discuss Using an IF function in a WHERE clause in the comp.databases.btrieve forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Robin
 
Posts: n/a

Default Using an IF function in a WHERE clause - 11-04-2004 , 06:02 PM






Hi,

I need to build a query with a WHERE clause for a Crystal report that
essentially tests for something and if true, builds the rest of the
WHERE clause one way, and if false, builds the rest another way. I
would like to be able to do something like this:

WHERE LeaseCompany.LeaseCompanyNum = '09' AND
LeaseDatabase.LeaseTerminationDate = 0 AND
OpeninvAutoSchedule.AutoSchSeqNum = 1 AND
LeaseEquipment.EquipSaleInvDate = 0 AND
IF(LeaseDatabase.LeaseMaturityDate > 20041104,
OpeninvAutoSchedule.AutoschNum = 1,
OpeninvAutoSchedule.AutoScheduleStartDate1 >=
LeaseDatabase.LeaseMaturityDate AND OpeninvAutoSchedule.AutoschNum >
1)

However when I try to run this I get an ODBC Error (right after the
first OpeninvAutoSchedule.AutoschNum it chokes). Is it possible to do
what I'm trying to do another way?

Thanks very much for any help or suggestions.


Robin

Reply With Quote
  #2  
Old   
Robin
 
Posts: n/a

Default Re: Using an IF function in a WHERE clause - 11-11-2004 , 05:26 PM






The solution is as follows:

WHERE LeaseCompany.LeaseCompanyNum = '09' AND
LeaseDatabase.LeaseTerminationDate = 0 AND
OpeninvAutoSchedule.AutoSchSeqNum = 1 AND
LeaseEquipment.EquipSaleInvDate = 0 AND (
(LeaseDatabase.LeaseMaturityDate > 20041104 AND
OpeninvAutoSchedule.AutoschNum = 1) OR
(LeaseDatabase.LeaseMaturityDate <= 20041104 AND
OpeninvAutoSchedule.AutoScheduleStartDate1 >=
LeaseDatabase.LeaseMaturityDate AND OpeninvAutoSchedule.AutoschNum >
1))

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.