select top 20 Projects.id,Projects.Project_PayMin,Projects.Project_PayMax,
Projects.Project_SelectBiddingPay,Projects.Project_Name,Projects.Project_EndTime,
Projects.Project_State ,Projects.Project_Class
from Projects inner join Project_Type on Projects.Project_Type=Project_Type.id
where Project_State<>0 and Project_State<>5
and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1 and Projects.id
not in (select top 0 Projects.id from Projects where Project_State<>0
and Project_State<>5 and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1 order by Projects.Project_BeginTime desc)
order by Projects.Project_BeginTime desc就这个SQL 语句 数据有点多 执行有点慢
Projects.Project_SelectBiddingPay,Projects.Project_Name,Projects.Project_EndTime,
Projects.Project_State ,Projects.Project_Class
from Projects inner join Project_Type on Projects.Project_Type=Project_Type.id
where Project_State<>0 and Project_State<>5
and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1 and Projects.id
not in (select top 0 Projects.id from Projects where Project_State<>0
and Project_State<>5 and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1 order by Projects.Project_BeginTime desc)
order by Projects.Project_BeginTime desc就这个SQL 语句 数据有点多 执行有点慢
解决方案 »
- 简单触发器疑问
- 这段SQL语句if CONVERT(real,dbo.colval(@row,'条形码'))=1是什么意思
- 用友财务通恢复后找不到帐套,用过用友财务通的请进!
- 有没有什么工具,可以把字段的描述导出来的?
- 从父表里查询字表的条数
- 能不能用Excel做前端,连接和访问后台的SQLServer数据库??
- sql server 遍历表,不使用游标和临时表
- 大家帮忙看一下,错在哪里?(刚学存储过程)在线等待........
- 有一系统服务器端用的是sqlserver2000。有的客户端只能拨号到服务器端,不知道怎样来实现?
- 连接SQL SERVER 数据库后,使用RECORDSET对象的时候出现问题!很奇怪,大家都来讨论讨论!
- 求一sql语句 (记录在表中的比率)
- 这条SQL如何写?高手来!有难度!
Projects.Project_SelectBiddingPay,Projects.Project_Name,Projects.Project_EndTime,
Projects.Project_State ,Projects.Project_Class
from Projects inner join Project_Type on Projects.Project_Type=Project_Type.id
where Project_State<>0 and Project_State<>5
and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1 and Projects.id
not in (select top 0 Projects.id from Projects where Project_State<>0
and Project_State<>5 and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1 order by Projects.Project_BeginTime desc)
order by Projects.Project_BeginTime desc如果是 top 0 ,那么这整句都没用,可以省
Projects.Project_SelectBiddingPay,Projects.Project_Name,Projects.Project_EndTime,
Projects.Project_State ,Projects.Project_Class
from Projects
inner join Project_Type on Projects.Project_Type=Project_Type.id
where Project_State NOT IN (0,5,6) and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1
order by Projects.Project_BeginTime desc
你那个NOT IN TOP 0给你删掉了
应该是写select top 10 吧不然后面写这么多判断干吗
(select row=row_number() over(order by Projects.Project_BeginTime desc),Projects.id,Projects.Project_PayMin,Projects.Project_PayMax,
Projects.Project_SelectBiddingPay,Projects.Project_Name,Projects.Project_EndTime,
Projects.Project_State ,Projects.Project_Class
from Projects inner join Project_Type on Projects.Project_Type=Project_Type.id
where Project_State<>0 and Project_State<>5
and Project_State<>6 and (Project_Pay_isTrust=1 or WKSiteid<>11)
and Project_TypeFatherId=1)a
where row between 1 and 20