--例子select a.id , count(a.数量) 数量 ,sum(a.金额) 金额 into newtablename from table1 a , table2 b where a.id = b.id group by id
看错了,是要生成表,select *** into #tb from table where ...
select sum(总数量) as '',sum(金额) as '总金额' into test--生成表名 from (select sum(数量) as '数量',sum(金额) as '金额' from table1 union all select sum(数量),sum(金额) from table2 union all select sum(数量),sum(金额) from table3)taselect [总数量]=sum(table1.数量)+sum(table2.数量)+sum(table3.数量), [总金额]=sum(table1.金额)+sum(table2.金额)+sum(table3.金额) into test--生成表名 from table1,table2,table3
from table1 a , table2 b
where a.id = b.id
group by id
into #tb
from table
where ...
into test--生成表名
from (select sum(数量) as '数量',sum(金额) as '金额' from table1
union all
select sum(数量),sum(金额) from table2
union all
select sum(数量),sum(金额) from table3)taselect [总数量]=sum(table1.数量)+sum(table2.数量)+sum(table3.数量),
[总金额]=sum(table1.金额)+sum(table2.金额)+sum(table3.金额)
into test--生成表名
from table1,table2,table3