程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> row num-關於設置參數值和直接拼接SQL語句問題

row num-關於設置參數值和直接拼接SQL語句問題

編輯:編程綜合問答
關於設置參數值和直接拼接SQL語句問題

DECLARE @SysBranchSysNo int,@C1SysNo int,@RepeatNum INT
SET @SysBranchSysNo=1;
SET @C1SysNo=1073;
SET @RepeatNum=1
SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Quantity desc ) AS DATA_ROW_NUM, * FROM (
SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY SysNo,SysBranchSysNo ORDER BY totalNum) as RepeatNum,* FROM dbo.v_product) Product
WHERE SysBranchSysNo=@SysBranchSysNo
AND C1SysNo=@C1SysNo AND RepeatNum=@RepeatNum AND onlineqty>0 ) A) B WHERE DATA_ROW_NUM BETWEEN 181 AND 200;
為什這條語句執行結果是沒數據,如果把WHERE SysBranchSysNo=@SysBranchSysNo改成WHERE SysBranchSysNo=1這樣的執行結果就有值了。

最佳回答:


找到原因了,改成這樣就行了
DECLARE @SysBranchSysNo int,@C1SysNo int,@RepeatNum INT
SET @SysBranchSysNo=1;
SET @C1SysNo=1073;
SET @RepeatNum=1
SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Quantity desc ) AS DATA_ROW_NUM, * FROM (
SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY SysNo,SysBranchSysNo ORDER BY totalNum) as RepeatNum,* FROM dbo.v_product
WHERE SysBranchSysNo=@SysBranchSysNo
) Product
WHERE C1SysNo=@C1SysNo AND RepeatNum=@RepeatNum AND onlineqty>0 ) A) B WHERE DATA_ROW_NUM BETWEEN 181 AND 200;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved