ms sql :select * from (select *from b) as xxx where 和 select

thinkinglj2022-10-04 11:39:541条回答

ms sql :select * from (select *from b) as xxx where 和 select * from (select *from b) xxx where区
select * from (select *from b) as xxx where…… 和 select * from (select *from b) xxx where……的区别
别告诉我是一样的.
因为我有一个存储过程
set @query= 'select *
from (select Food.*,Supplier.SupplierName,Row_number()over( '+@orderQuery+' ) as IDRank from '+@tableName+' ' +@checkQuery+' ) xx
where xx.IDRank between ……(省略了)'
这个是对的.
我改成
set @query= 'select *
from (select Food.*,Supplier.SupplierName,Row_number()over( '+@orderQuery+' ) as IDRank from '+@tableName+' ' +@checkQuery+' ) as xx
where IDRank between……(省略了)‘
之后,也可以执行
但是如果改为
set @query= 'select *
from (select Food.*,Supplier.SupplierName,Row_number()over( '+@orderQuery+' ) as IDRank from '+@tableName+' ' +@checkQuery+' )
where IDRank between……(省略了)‘
就不能执行了

已提交,审核后显示!提交回复

共1条回复
潇潇斩斗戟 共回答了18个问题 | 采纳率88.9%
select * from (select *from b) as xxx where
select * from (select *from b) xxx where
确实是一样的,但是第三句相当于
select * from (select *from b) where
这个有错误.
1年前

相关推荐

关于MS SQL中的问题,DECLARE @i INTEGERDECLARE @iTest INTEGERSET @iT
关于MS SQL中的问题,
DECLARE @i INTEGER
DECLARE @iTest INTEGER
SET @iTest = 59
SET @i=2
WHILE @i
超人88881年前1
uu咖啡猫 共回答了17个问题 | 采纳率94.1%
DECLARE @i INTEGER
DECLARE @iTest INTEGER
SET @iTest = 59
SET @i=2

WHILE @i<@iTest
BEGIN

IF@iTest%@i=0
BEGIN
PRINT '该数不是素数'
END


ELSE
BEGIN
SET @i=@i+1
IF @Itest=@i
PRINT '该数是素数'
END
END
另外你检查下你算法,是不是有问题,这样运行是没问题了