从多个select中插入单个表

时间:2015-11-02 16:19:29

标签: sql insert

我需要在另一个表的2列中插入10列(5对)。我尝试了很多方法:

SELECT device_id,
       event_time,
       unix_time,
       event_id,
       lag(event_time) OVER (PARTITION BY device_id ORDER BY unix_time,event_id) AS lag_time
FROM ios_d_events;

所有a,b列都来自相同的数据类型

1 个答案:

答案 0 :(得分:3)

如果您想避免重复,可以使用UNION ALLUNION

insert into table1(a,b) 
select a1,b1 from table2
UNION ALL
select a2,b2 from table2;

LiveDemo