我在修改SSIS转换的连接键时遇到了一些麻烦。
SELECT year_time, substring(rtrim(cast(region_code+county_code+district_code as varchar(100)), 5,4)as DR, rtrim(ltrim(T1.district_name)) as 'DNR', SUM(CAST(K12 AS INT)) AS 'TR'
FROM Database_Table
GROUP BY year_time, region_code+county_code+district_code, district_name
order by year_time, district_code_raw, district_name_raw
我收到一个错误,我的rtrim函数需要1个参数。我相信错误是在连接上。
答案 0 :(得分:1)
您缺少括号来关闭RTRIM()
:
SELECT year_time,
substring(rtrim(cast(region_code+county_code+district_code as varchar(100))), 5,4)as DR,
rtrim(ltrim(T1.district_name)) as 'DNR', --^--missing
SUM(CAST(K12 AS INT)) AS 'TR'
FROM Database_Table
GROUP BY year_time, region_code+county_code+district_code, district_name
order by year_time, district_code_raw, district_name_raw