SELECT B.code + '-' + LEFT(F.code, 1) + '-'
+ CAST(ROW_NUMBER() OVER (PARTITION BY AT.[description]
ORDER BY ID) AS VARCHAR(10)) AS [code]
+ '-' + AST.CODE,
我厌倦了()很少的选择,但没有用
SELECT B.code + '-' + LEFT(F.code, 1) + '-'
+ CAST(ROW_NUMBER() OVER (PARTITION BY AT.[description]
ORDER BY ID) AS VARCHAR(10)) AS [code]
+ '-' + AST.CODE,
答案 0 :(得分:4)
您已将“ AS [code]”放在字符串操作内的错误位置。试试这个
SELECT B.code + '-' +
LEFT(F.code, 1) + '-' +
CAST(ROW_NUMBER() OVER (PARTITION BY AT.[description] ORDER BY ID) AS VARCHAR(10)) +
'-' + AST.CODE AS [code]