select 姓名,超產獎,sum(iif(月份<Month(Now()),次數,0)) As 累計本月以前_次數,sum(iif(月份 <Month(Now()),金額,0)) As 累計本月以前_金額, sum(iif(月份=Month(Now()),次數,0)) As 本月_次數 ,sum(iif(月份=Month(Now()),金額,0)) As 本月_金額 From{表A} GrouP by 姓名,超產獎 UNION select 姓名 & '小計' as 姓名,'' as 超產獎,sum(iif(月份<Month(Now()),次數,0)) As 累計本月以前_次數,sum(iif(月份 <Month(Now()),金額,0)) As 累計本月以前_金額, sum(iif(月份=Month(Now()),次數,0)) As 本月_次數 ,sum(iif(月份=Month(Now()),金額,0)) As 本月_金額 From{表A} GrouP by 姓名 & '小計'
|