具有多个select语句的最大值

时间:2017-10-03 19:02:57

标签: sql-server-2012

请帮我从下面的查询中获取MAX AuditId(来自CheckDetailAddendumA表)值。

Select * from CheckDetailAddendumA
Where BusinessDate = '20041110'
and AuditID in (select AuditID from payments where paymentid in (select PaymentID from PaymentLinks where BusinessDate = '20041110' and ItemID = 11451163))
Order by AuditID

提前致谢!!!

1 个答案:

答案 0 :(得分:0)

试试这个

   Select * from CheckDetailAddendumA
    Where BusinessDate = '20041110'
    and AuditID = (select MAX(AuditID) from payments where paymentid in 
                     (select PaymentID from PaymentLinks where BusinessDate = '20041110' and ItemID = 11451163))