我正在使用查询来更新具有百分比的表字段,并且我想知道是否有一种方法可以在输出的末尾附加%符号。我的代码如下:
UPDATE TM_SCRIPT_SUMMARY_STATUS SET
EXEC_PERC_COMP = (SELECT CONVERT(decimal(5, 2),(CONVERT(numeric, EXEC_COMP) / CONVERT(numeric, SCRIPT_TOTAL)) * 100.0)
WHERE IMP_NAME = 'TEST RELEASE DEMO'
AND PROJECT_ID = 'testingproject')
WHERE IMP_NAME = 'TEST RELEASE DEMO'
AND PROJECT_ID = 'testingproject')
答案 0 :(得分:0)
尝试转换为varchar,并附加%。
,而不是转换为十进制UPDATE tm_script_summary_status
SET exec_perc_comp =
(
SELECT CONVERT(VARCHAR(8),(CONVERT(DECIMAL(5,2), exec_comp) / CONVERT(DECIMAL(5,2), script_total)) * 100.0) + '%'
FROM <tablename>
WHERE imp_name = 'TEST RELEASE DEMO'
AND project_id = 'testingproject'
)
WHERE imp_name = 'TEST RELEASE DEMO'
AND project_id = 'testingproject')