数据库表是每天一个,汇总一周数据的问题

zhujinqiang 2007-12-12 09:24:37
一周有7天,我现在是分7次select
把结果insert到中间表保存。

有没有更简便的方法?
...全文
133 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinqi025 2008-01-12
  • 打赏
  • 举报
回复
为什么不
insert into 中间表
select * from t1 where 时间in七天内?
duanzhi1984 2008-01-11
  • 打赏
  • 举报
回复
如果要把表插入到另外的一个数据表,则


insert into 中间表
select * from t1
union all
select * from t2
union all
select * from t3
union all
select * from t4
union all
select * from t5
union all
select * from t6
union all
select * from t7
duanzhi1984 2008-01-11
  • 打赏
  • 举报
回复
create view TotalTable
as

select * from t1
union all
select * from t2
union all
select * from t3
union all
select * from t4
union all
select * from t5
union all
select * from t6
union all
select * from t7

GO


这七个表的结构必须一致。

以后就直接访问视图TotalTable
就可以了
zhujinqiang 2008-01-11
  • 打赏
  • 举报
回复
创建视图怎木写?
晓风残月0110 2007-12-12
  • 打赏
  • 举报
回复
创建视图也可以
dawugui 2007-12-12
  • 打赏
  • 举报
回复
select * into 中间表 from
(
select * from t1
union all
select * from t2
union all
select * from t3
union all
select * from t4
union all
select * from t5
union all
select * from t6
union all
select * from t7
) t
playwarcraft 2007-12-12
  • 打赏
  • 举报
回复
select * from t1
union all
select * from t2
union all
select * from t3
...

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧