我需要将两列的总和除以总数。两列都是十进制数据类型。这是我迄今为止所拥有的,但它不起作用。
SELECT total_salary / DistEnroll
FROM dbo.vw_Salary
WHERE DistEnroll = (
SELECT DISTINCT(distenroll)
FROM dbo.vw_Salary
WHERE YEAR = '2012'
AND dist_name = 'Sch Dist'
)
AND total_salary = (
SELECT SUM(total_salary)
FROM [vw_salary]
WHERE YEAR = '2012'
AND dist_name = 'Sch Dist'
)