注册 登录
编程论坛 SQL Server论坛

仓库的问题 计算出问题(语法问题)

copy462829 发布于 2008-04-02 12:11, 1213 次点击
select a.uid,
(
select  isnull (sum(x.number),0) from m_stockcontent as x where   x.spid='1' and x.oddtype=1
- select isnull(sum(c.number),0) from m_stockcontent as c where  c.spid='1' and c.oddtype=2
-select isnull(sum(v.number),0) from m_sellcontent as v where  v.spid='1' and v.oddtype=3
+ select isnull(sum(b.number),0) from m_sellcontent as b where  b.spid='1' and b.oddtype=4
-  select isnull(sum(n.number),0) from m_sellcontent as n where  n.spid='1' and n.oddtype=5
+select isnull(sum(m.number),0) from m_sellcontent as m where  m.spid='1' and m.oddtype=6
-select isnull(sum(l.sl),0) from m_bssp as l where l.spid='1' )
as kc
from m_users as a

服务器: 消息 156,级别 15,状态 1,行 3
在关键字 'select' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 4
在关键字 'select' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 5
在关键字 'select' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 6
在关键字 'select' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 7
在关键字 'select' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 8
在关键字 'select' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 8
第 8 行: ')' 附近有语法错误。

(
select  isnull (sum(x.number),0) from m_stockcontent as x where   x.spid='1' and x.oddtype=1
- select isnull(sum(c.number),0) from m_stockcontent as c where  c.spid='1' and c.oddtype=2
-select isnull(sum(v.number),0) from m_sellcontent as v where  v.spid='1' and v.oddtype=3
+ select isnull(sum(b.number),0) from m_sellcontent as b where  b.spid='1' and b.oddtype=4
-  select isnull(sum(n.number),0) from m_sellcontent as n where  n.spid='1' and n.oddtype=5
+select isnull(sum(m.number),0) from m_sellcontent as m where  m.spid='1' and m.oddtype=6
-select isnull(sum(l.sl),0) from m_bssp as l where l.spid='1' )
as kc

这段该如何实现
2 回复
#2
makebest2008-04-02 21:53
好奇怪的语句,试着把每个子查询都加上括号吧!
#3
lff6422008-04-25 18:02
应该加上括号,
1