Skip to content
Advertisement

Case Statement within in Statement in MS SQL

I want to compare two different tables in IN statement based on condition.

ERROR : Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Error is in following lines:

I am not able to use case when in IN statement. if I write WHERE cts.ContactType In (SELECT Code From v2010_ListEntries WHERE ListId=’CONTACTTYPESC’) it is working but I want to compare condition and based on condition compare table.

Advertisement

Answer

It is a bit hard to tell where the multiple rows problem is coming from, but I am thinking:

Or, more simply as:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement