Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Covert Nested Access IIF to CASE
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01435355
Message ID:
01435357
Views:
28
>What's the correct syntax for converting this to SQL:
>
>
>IIf(IIf(CAST(RQ.RQ_JOB AS DECIMAL) < sf.PeriodOrderedQty, 0, CAST(RQ.RQ_JOB AS DECIMAL)- sf.PeriodOrderedQty) <> RQ.RQ_QTY_REQ,'Yes','') AS [Update PK Qty Required?], 
>
>
>Thanks


IIF translates to CASE statement, so
CASE when (case when CAST(RQ.RQ_JOB AS DECIMAL(19,4)) < sf.PeriodOrderedQty 
then 0 else CAST(RQ.RQ_JOB AS DECIMAL(19,4))- sf.PeriodOrderedQty end) = RQ.RQ_QTY_REQ 
then '' else 'Yes' end as  [Update PK Qty Required]
See also http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/always-include-precision-and-scale-with about why did I do another change (specified scale and precision for the decimal).
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform