sql 如何把查询得到的结果如何放入一个新表中

如何把这个查询到的结果放到一张新表中?

第1个回答  推荐于2017-12-15
表已经存在;
insert into 表名 (列名1.。。 列名n) select 列名1.。。。列名n from 表 where 条件
表不存在.
oracle
create table 新表明 as select 列名1.。。。列名n from 表 where 条件
sqlserver
select 列名1.。。。列名n
into 新表名
from 表 where 条件追问

没有原表,我通过
select collection_date,pub_date,count(*) as 'sum' from r_time
group by pub_date,collection_date
这个语句得到的新表,具体怎么才能放到一张新表中,能不能写详细点?

追答

oracle
crate table 新表名
select collection_date,pub_date,count(*) as 'sum' from r_time
group by pub_date,collection_date
sqlserver
select collection_date,pub_date,count(*) as 'sum'
into 新表名
from r_time
group by pub_date,collection_date

本回答被提问者采纳
第2个回答  2018-03-31

oracle crate table 新表名 select collection_date,pub_date,count(*) as 'sum' from r_time group by pub_date,collection_date .

举例:
1、select a.stk_c,b.name,cat_c3 from (select stk_c from stk_dtl where stk_qty>0 group by stk_c) a,stk_mas b where a.stk_c=b.stk_c

2、select * from (SELECT SUM(NUM_QNTY4) AS sumNum, NUM_LINKID FROM RW_STORE_QUNTY GROUP BY NUM_LINKID ) a left join b on a.NUM_LINKID =b.NUM_LINKID 
where a.NUM_LINKID = 1002

3、select a.realname,b.username from sa_member a,(select username2 as username,is_agree from sa_MemberFriend where username1='jhgjhg' union all select username1 as username,is_agree from

本回答被网友采纳
第3个回答  2014-03-13
select * into table2 from table1
table1是要查询的表
table2是新表
第4个回答  2014-03-13
oracle:insert into new_table select * from old_table
相似回答