select * into a from ( select * from old_table union select sum(*) lists from new_table )我能拿分码?
建议不要用名字做字段名,如果你硬要实现的话可以这样写: select 张三,李四 from TableName union select sum(张三),sum(李四) from TableName;
select sum(张三) ,sum( 李四) from youtable group by lesson with rollup
select lesson ,sum(张三) ,sum( 李四) from youtable group by lesson with rollup
不明白你这个表怎么用? 人员变化了, 还改表结构不成? 不是好办法.按你的要求, 试试下面的:select ' ' as A, 课程名称, 张三,李四 from TableName union all select '合计' as A, 课程名称, sum(张三) as 张三, sum(李四) as 李四 from TableName order by A
上面好像不对, 下面的对不?select ' ' as A, 课程名称, 张三,李四 from TableName union all select '合计' as A, '' as 课程名称, (select sum(张三) from TableName) as 张三, (select sum(李四) from TableName) as 李四 order by A
( select * from old_table
union
select sum(*) lists from new_table )我能拿分码?
select 张三,李四 from TableName union
select sum(张三),sum(李四) from TableName;
union all
select '合计' as A, 课程名称, sum(张三) as 张三, sum(李四) as 李四 from TableName
order by A
union all
select '合计' as A, '' as 课程名称,
(select sum(张三) from TableName) as 张三,
(select sum(李四) from TableName) as 李四
order by A