我已经写了这个查询;我需要帮助分配变量;这是来自其他查询,我该怎么做。
我怎样才能将它们结合在一起?
查询 1
Select SUM(Credit)
FROM(SELECT TOP 1 Credit
FROM (SELECT DISTINCT TOP 2 Ref, Credit, PaymentID
FROM Payment where Ref = '????' AND PaymentID <= '????'
ORDER BY PaymentID DESC)
a ORDER BY PaymentID)
b
查询 2
Select Ref, PaymentID
From Payment
Where PaymentDate = '2012-09-23'
所以我需要查询 2 的 Ref 和 PaymentID 并在查询 1 中用作变量