日期:2014-05-18  浏览次数:20495 次

急求sql 语句
我用的是sql2000sever   个人版
现在无法运行这个语句
create   view   AllOrder   as  
select   *   from   DsOrder  
              UNION   ALL(select   *   from     DhOrder)
              UNION   ALL(select   *   from     XlOrder)  
              UNION   ALL(select   *   from     XsOrder)
select   Name,(A1.Number+A2.Number)   Number
from   AllOrder   A1
where   A1.Name=(select   A2.Name  
                              from   AllOrder   A2);

DsOrder   属性(Name   ,Number   ,Time   ,Shop   )
DhOrder   属性(Name   ,Number   ,Time   ,Shop   )
XlOrder   属性(Name   ,Number   ,Time   ,Shop   )
XsOrder   属性(Name   ,Number   ,Time   ,Shop   )
  我的目的是把DsOrder、DhOrder、XlOrder、XsOrder中具有相同属性Name的Number相加,最后显示在屏幕上
那位大哥能给指点一下
小弟谢过了

------解决方案--------------------
select name,sum(number) from (
select * from DsOrder
UNION ALL(select * from DhOrder)
UNION ALL(select * from XlOrder)
UNION ALL(select * from XsOrder)
)t group by name