根据功能的结果订购结果

时间:2014-03-19 11:11:47

标签: sql-server tsql

我使用以下查询但发生错误

  

无效的列名钱

select * from (SELECT  ROW_NUMBER() OVER (order by money desc) as row,
                            ChargeLog.customerCode,(select taraz from getCustomerMoney(ChargeLog.customerCode)) as money
                             from ChargeLog 
                            )tblTemp
                            WHERE row between  (1 - 1) * 20 + 1 AND 1*20

1 个答案:

答案 0 :(得分:1)

试试这个:

WITH T AS 
(   SELECT  ChargeLog.customerCode,
            (select taraz from getCustomerMoney(ChargeLog.customerCode)) as money
            from ChargeLog 
), T2 AS 
(
   SELECT ROW_NUMBER() OVER (order by money desc) as row,
          customerCode,
          Money
          FROM T           
)
SELECT * FROM T2 WHERE row between  (1 - 1) * 20 + 1 AND 1*20