I have a Postgres WHEN case query error. How can I fix the query?
SELECT CASE
WHEN AccountStatus='Open'
THEN
(
SELECT *
from Accounts
where statusID=1
)
WHEN AccountType='Mutual'
THEN
(
SELECT *
FROM Accounts
WHERE AccountTypeID=2
)
END as Status, *
FROM Accounts
Showing Error:
more than one row returned by a subquery used as an expression
Accountstable that has aStatusID=1orStatusID=2. How would you suspect it would display MANY records in a single record of your result set? If you share some sample data and your desired results we can guide you to a proper way of getting what you want.