我现在已经查出了所有人在11年的平均工资,但是我还想直接得出这些人平均工资的总额,请教SQL如何写,已实现的SQL语句如下:
select SUM(发合计)/COUNT(distinct SUBSTRING(年月,1,6)) as sums from 工资 where 客户ID='7295' and 年月 like '2011%' group by 雇员ID
我现在已经查出了所有人在11年的平均工资,但是我还想直接得出这些人平均工资的总额,请教SQL如何写,已实现的SQL语句如下: select SUM(发合计)/COUNT(distinct SUBSTRING(年月,1,6)) as sums from 工资 where 客户ID='7295' and 年月 like '2011%' group by 雇员ID 目前结果如下: sums 7389.165 5064.1725 6815.554166 3208.5925 5839.130833 386
with A AS(
select SUM(发合计)/COUNT(distinct SUBSTRING(年月,1,6)) as sums
from 工资 where 客户ID='7295'
and 年月 like '2011%' group by 雇员ID
)
SELECT SUMS, SUM(SUMS)OVER() TOTAL
FROM A