From case when... on SQLServer to decode

Original text of this message