Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Code This VFP IIF Statement In SQL
Message
From
23/06/2008 12:50:08
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01326128
Message ID:
01326142
Views:
26
Actually he's trying to use a boolean expresion in a simple case statement. I was correcting my answer when you replied. Sergey already gave him the correct answer.



>>That second WHEN should be OR I think.
>>
>
>That's the original requirement
>
>IIF(((TRANCODE="PR") .OR. (TRANCODE = "PT" .AND. TRANQUANT > 0)),TRANQUANT,0) AS Recepit
>
>so it translates into 2 case statements.
>
>
>>>The problem now is that SQL doesn't seem to like the 'AND' in the second CASE line.
>>>
>>>CASE tr.sTrans_Type_CD
>>>	WHEN 'PR' THEN tr.decTrans_Qty
>>>	WHEN ('PT' AND tr.decTrans_Qty > 0) THEN tr.decTrans_Qty
>>>	ELSE 0
>>>END AS Receipt
>>>
>>>
>>>"Incorrect syntax near the keyword 'AND'."
>>>
>>>
>>>>>
>>>>>SQL doesn't like the 'OR's and 'AND's
>>>><snip>
>>>>T-SQL doesn't like '.' (dots) arround them. There's no need to use dots in VFP either.
>>>>
>>>>CASE WHEN (TRANCODE = 'PR') OR (TRANCODE = 'PT' AND TRANQUANT > 0) THEN TRANQUANT
>>>>     ELSE 0 END AS Recepit
>>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform