当前位置: 动力学知识库 > 问答 > 编程问答 >

sql - Append String Value To Int Column

问题描述:

I am running a query just a simple Select Statement, how can I append (from within the query) a value to my int column? I have tried the below, but keep getting this error:

Msg 245, Level 16, State 1, Line 1

Syntax error converting the varchar value 'Month ' to a column of data type int.

SELECT a.Sales, SUM(a.Count) As Count, CONVERT(INT, 'Month ') + dt.CumulativeMonth

FROM Rep a

INNER JOIN Date dt

ON a.Date = dt.FD

GROUP BY dt.CumulativeMonth, a.Sales

网友答案:

Here you go.

SELECT a.Sales, SUM(a.Count) As Count, 'Month ' + CONVERT(VARCHAR(20), dt.CumulativeMonth)
FROM Rep a
INNER JOIN Date dt
ON a.Date = dt.FD
GROUP BY dt.CumulativeMonth, a.Sales
分享给朋友:
您可能感兴趣的文章:
随机阅读: