TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
741
1.2k
281.9k
Subquery returned more than 1 value
Jul 29 2020 2:41 AM
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'
Error says:
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.
Reply
Answers (
2
)
How to Covert List<string> values to Enum
Search Two words in datagrid c#