我在报告中有一个特定的场景,我希望以特定格式获得一个月。
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
答案 0 :(得分:0)
我认为这对你有用:
SELECT CASE
WHEN @month = 0 THEN ''
ELSE RIGHT ('0' + @month, 2)
END AS Month