Is it possible to combine these case statements

Database

Is it possible to combine these case statements

CASE WHEN TO.PRODUCT = 'Bag'
THEN (

CASE WHEN CP.TO_sale_TYPE = 'DYNAMIC'
THEN 'Sell'
WHEN CP.TO_sale_TYPE = 'STATIC'
THEN 'Sell-s'
ELSE 'Sell-UNKNOWN' END

)

CASE WHEN From.PRODUCT = 'Bag'
THEN (
CASE WHEN CP.From_sale_TYPE = 'DYNAMIC'
THEN 'Sell'
WHEN CP.From_sale_TYPE = 'STATIC'
THEN 'Sell-s'
ELSE 'Sell-UNKNOWN' END
)
Could these two case statements be combined using an 'In' or any other options could be done?
1 REPLY
Enthusiast

Re: Is it possible to combine these case statements

Try this....
CASE
WHEN TO.PRODUCT = 'Bag' AND From.PRODUCT = 'Bag'
THEN
(
CASE
WHEN CP.TO_sale_TYPE = 'DYNAMIC' AND CP.From_sale_TYPE = 'DYNAMIC'
THEN 'Sell'
WHEN CP.TO_sale_TYPE = 'STATIC' AND CP.From_sale_TYPE = 'STATIC'
THEN 'Sell-s'
ELSE
'Sell-UNKNOWN'
END
)
END