union all 简单用法

select Y.ID,sum(cast(Y.m as int)) as he
from
(select top 10 a.ID,a.AlarmSource as m from dbo.AlarmInfo a
union all
select top 10 B.ID,B.AssetCode as m from dbo.AuxiliaryToolInfo B
)Y
group by Y.ID

 

select top 10 A.* from dbo.AlarmInfo A;
select top 10 B.* from dbo.AuxiliaryToolInfo B

select * from dbo.MES_DataRealtime

posted on 2015-05-12 17:49  chengjunde  阅读(568)  评论(0)    收藏  举报

导航