syscomments

RocketScientist's Miscellaneous Ramblings
posts - 76, comments - 354, trackbacks - 3

Someone might not understand how CASE works....

    case when StatusFlag = 'LWCA' and TransactionType <> 'W' then 'Layw Cancel'
        ELSE
    case when StatusFlag = 'LWCA' and TransactionType = 'W' then 'Warranty Cancel'
        ELSE
    case when StatusFlag = 'WAPK' then 'Warranty Pickup'
        ELSE
    case when StatusFlag = 'LWSE' and TransactionType <> 'W' then 'Layaway'
        ELSE
    case when StatusFlag = 'LWSE' and TransactionType = 'W' then 'Warranty Setup'
        ELSE
    case when StatusFlag = 'SALE' and isnull(HV.QTY,0) > 0 and layawaynumber is null then 'Sale'
        ELSE
    case when StatusFlag = 'SALE' and isnull(HV.QTY,0) > 0 and NOT layawaynumber is null then 'Lwy Pickup'
        ELSE
    case when StatusFlag = 'SALE' and isnull(HV.QTY,0) <= 0 then 'Return'
    End End End End End End End End,

Print | posted on Tuesday, May 05, 2009 9:35 AM |

Feedback

Gravatar

# re: Someone might not understand how CASE works....

Maybe they are aiming for the Obfuscated C(equal) award?
5/5/2009 11:01 AM | Brian Tkatch
Gravatar

# re: Someone might not understand how CASE works....

You should provide the correct way to write it so people may compare:

case
when StatusFlag = 'LWCA' and TransactionType <> 'W' then 'Layw Cancel'
when StatusFlag = 'LWCA' and TransactionType = 'W' then 'Warranty Cancel'
when StatusFlag = 'WAPK' then 'Warranty Pickup'
when StatusFlag = 'LWSE' and TransactionType <> 'W' then 'Layaway'
when StatusFlag = 'LWSE' and TransactionType = 'W' then 'Warranty Setup'
when StatusFlag = 'SALE' and isnull(HV.QTY,0) > 0 and layawaynumber is null then 'Sale'
when StatusFlag = 'SALE' and isnull(HV.QTY,0) > 0 and NOT layawaynumber is null then 'Lwy Pickup'
when StatusFlag = 'SALE' and isnull(HV.QTY,0) <= 0 then 'Return'
End,
5/7/2009 10:17 AM | Pollus Brodeur
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET