标题:请问下如何将临时表数据插入一张新表
只看楼主
wiers
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2023-2-17
 问题点数:0 回复次数:0 
请问下如何将临时表数据插入一张新表
程序代码:
with test as (
select '2023-02-04 19:08:52' [rq_]
union all 
select '2023-02-04 19:05:54'
union all 
select '2023-02-04 19:03:23'
union all 
select '2023-02-04 19:01:43'
union all 
select '2023-02-04 19:00:43'
union all 
select '2023-02-04 18:57:08'
union all 
select '2023-02-04 18:53:20'
)
SELECT T.*,DATEDIFF(SS,rq_,NEW_) [时差] FROM (
select A.*,(SELECT TOP 1 B.RQ_ FROM TEST B WHERE A.rq_>B.rq_ ORDER BY B.rq_ DESC) [NEW_] FROM test A
) T 
搜索更多相关主题的帖子: select FROM 插入 union 临时表 
2023-02-17 16:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-511316-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.121929 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved