Can someone help me solve the error of my query?
- UPDATE [dbo].[fin_PaymentSchedule_Master]
- SET
- ActualPaymentDate_ColS = GETDATE()
- ,[PaymentVoucher_ColT] = 'PV-200780'
- ,pyLAK_ColU =
- (
- CASE
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'LAK'
- THEN
- (SELECT SUM(AmountPaid + Vat) FROM fin_PaymentVoucher_Details WHERE AP_Number = 'AP19-3131')
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'THB'
- THEN 0
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'USD'
- THEN 0
- END
- )
- ,pyTHB_ColV =
- (
- CASE
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'THB'
- THEN
- (SELECT SUM(CurAmtPaid) FROM fin_PaymentVoucher_Details WHERE AP_Number = 'AP19-3131')
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'LAK'
- THEN 0
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'USD'
- THEN 0
- END
- )
- ,pyUSD_ColW =
- (
- CASE
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'USD'
- THEN
- (SELECT SUM(CurAmtPaid) FROM fin_PaymentVoucher_Details WHERE AP_Number = 'AP19-3131')
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'LAK'
- THEN 0
- WHEN
- (SELECT TOP(1) CurrencyPayment FROM fin_PaymentVoucher_Header WHERE PV_No = 'PV-200780' ORDER BY Id DESC) = 'THB'
- THEN 0
- END
- )
- ,pyTotalLAK_ColX = (SELECT SUM(AmountPaid + Vat) FROM fin_PaymentVoucher_Details WHERE AP_Number = 'AP19-3131')
- WHERE AP_Number_ColA = 'AP19-3131'
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated. The code snipe above is only part of the sql transaction. thank you in advance.


Varun SetiaPosted Jul 29, 2020, 3:48 AM