查找语法错误

风之影子 2009-11-05 09:49:30
select top 10 MonitorID,dafcode,LeftPoleStress,BalanceStress,RightPoleStress,Displacement,MonitorTime,supportcode 
from [rtm_one] a inner join daf b on a.workfaceid=b.workfaceid
where [monitorid]>
(
select max([monitorid]) from
(
select top -10 [monitorid] from [rtm_one] where select count(monitorid) from rtm_one where dafcode=0 and monitortime between '2006-11-01' and '2006-11-15' order by [monitorid] asc
)as tblTmp
)
and select count(monitorid) from rtm_one where dafcode=0 and monitortime between '2006-11-01' and '2006-11-15' order by [monitorid] asc




错误提示如下:

消息 102,级别 15,状态 1,第 7 行
'-' 附近有语法错误。
消息 102,级别 15,状态 1,第 8 行
')' 附近有语法错误。
...全文
83 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiqi860819 2009-11-05
  • 打赏
  • 举报
回复
top -10 的问题吧
microsofttyc 2009-11-05
  • 打赏
  • 举报
回复
top -10 没见过
chaozi_249 2009-11-05
  • 打赏
  • 举报
回复
select top -10 [monitorid] from [rtm_one]
难不成Sql里面也有运算符重载
fwacky 2009-11-05
  • 打赏
  • 举报
回复

1,要给字段加上表的别名 列如: select top 10 a.MonitorID,b.dafcode.........
2,select top -10 [monitorid] from [rtm_one]
where select count(monitorid) from rtm_one where dafcode=0
修改成
select top 10 [monitorid] from [rtm_one]
where dafcode=0


fwacky 2009-11-05
  • 打赏
  • 举报
回复

select top -10 [monitorid] from [rtm_one]
where select count(monitorid) from rtm_one where dafcode=0

--这是啥意思?????
  • 打赏
  • 举报
回复
直接top 10
wzy_love_sly 2009-11-05
  • 打赏
  • 举报
回复
水族杰纶 2009-11-05
  • 打赏
  • 举报
回复
select top -10
-->
select top 10 ....oder by col desc
wsxcdx 2009-11-05
  • 打赏
  • 举报
回复
top -10
水族杰纶 2009-11-05
  • 打赏
  • 举报
回复
and select count(monitorid) from rtm_one where dafcode=0 and monitortime between '2006-11-01' and '2006-11-15' order by [monitorid] asc
??
华夏小卒 2009-11-05
  • 打赏
  • 举报
回复
没有这个用法
华夏小卒 2009-11-05
  • 打赏
  • 举报
回复
top -10 这什么意思

34,575

社区成员

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

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