(1)web
select name,subject,result from resultInfo
(2)函數
select name,sum(result) from resultInfo group by name
(3)spa
select name ,sum(result) as 總分 from resultInfo group by name with cube select case when grouping(name)=1 then '總計' else name end as 姓名 ,sum(result) as 總分 from resultInfo group by name with cube
grouping函數:若是列中的值來來自查詢數據,則grouping返回0,若是列中的值是cube產生的空值,則返回1code
(4)orm
select name ,sum(result) as 總分 from resultInfo group by name with rollup select case when grouping(name)=1 then '總計' else name end as 姓名 ,sum(result) as 總分 from resultInfo group by name with rollup
(5)blog
select name,subject,sum(result) as 總分 from resultInfo group by name,subject with cube
按第1、二個字段的和計和最後的總計ci
(6)select name,subject,sum(result) as 總分 from resultInfo group by name,subject with rollup
按第一個字段的總計和最後的合計it