1

我在报告中有一个特定的场景,我想以特定格式获得一个月。

Input : 
Month : 2 Digit OR 1 Digit OR 0

Expectation:
If I pass 2 Digit : e.g. 10 o/p should be 10
If I pass 1 Digit : e.g. 1  o/p should be 01
If I pass 0       : e.g. 0  o/p should be blank

but I need help to when I pass 0 and I get Blank.

Please Help / Advice
AT
4

1 回答 1

0

我认为这对你有用:

SELECT CASE
         WHEN @month = 0 THEN ''
         ELSE RIGHT ('0' + @month, 2)
       END AS Month 
于 2013-03-22T20:04:25.123 回答