CONVERTVARCHAR ROUNDSUMCASE WHEN 日期 = 2023-03-14 THEN 总销量 END OVER PARTITION BY 大区 督导 ORDER BY 日期 大区 督导 1000 NULLIFSUMCASE WHEN 日期 = 2023-03-14 THEN 全产品销量 END OVER PARTITION BY 大区 督导 ORDER BY 日期 大区
This SQL code converts the result of a calculation to a string format with a percentage symbol at the end. The calculation itself involves summing up the total sales for a specific period for each region and supervisor, and then dividing that by the total sales of all products for the same period. The resulting percentage is rounded to two decimal places using the ROUND function. The CONVERT function is then used to convert this result to a string format, which is concatenated with a percentage symbol using the '+' operator. The NULLIF function is also used to avoid division by zero errors.
原文地址: https://www.cveoy.top/t/topic/byd0 著作权归作者所有。请勿转载和采集!