將字符串值附加到Int列

[英]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語句,如何將(從查詢中)一個值附加到我的int列?我已嘗試過以下內容,但不斷收到此錯誤:消息245,級別16,狀態1,行1語法錯誤將varchar值'Month'轉換為數據類型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

1 个解决方案

#1


3  

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

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/02/10/72a0c19bf20f975710e25cbf0e9b7629.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com