怎样同时对两个结构完全一样的数据表进行查询,请高手指点!!!!

mgq_888 2002-09-17 01:17:50
在数据库中有两个结构完全一样的表:table1,table2。table1存放的当天的数据,table2存放的是历史数据。我想在统计查询的时候,同时对两个表进行操作,请问高手SQL语句怎么写,在线等待,急急!!!!
...全文
134 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
mgq_888 2002-09-17
  • 打赏
  • 举报
回复
stone_lin(石),太感谢你了,我刚才试过,对了 。感谢各为兄弟!!!!!!!!
日总是我哥 2002-09-17
  • 打赏
  • 举报
回复

够激烈^o^
j9988 2002-09-17
  • 打赏
  • 举报
回复
select sum(s1) from (
selelct sl from table1
union all
select sl from table2 ) a

j9988 2002-09-17
  • 打赏
  • 举报
回复
select sum(s1) from (
selelct sl from table1
union
select sl from table2 ) a

stone_lin 2002-09-17
  • 打赏
  • 举报
回复
Select sum(sl) from (selelct sum(sl) as sl from table1
union
select sum(sl) as sl from table2) as T
mgq_888 2002-09-17
  • 打赏
  • 举报
回复
我统计表中的一个字段:SL(数量)语句是:
selelct sum(sl) from table1
union
select sum(sl) from table2
统计出来的结果和我两个表分别统计出来的结果加起来的结果不一样啊
microlong 2002-09-17
  • 打赏
  • 举报
回复
select * from talbe1
union
select * from tagle2
日总是我哥 2002-09-17
  • 打赏
  • 举报
回复
Select * From Table1 Where xxxxxxxxxxxx
Union All
Select * From Table2 Where xxxxxxxxxxxx

34,873

社区成员

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

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