i am getting this error ( see title). How can i correct this:
sql
use adventureworks
go
select si.CustomerID,
'myField' =
CASE
When (Select Top 1 FirstName,LastName From Person.Contact pc Where si.ContactID = pc.contactid ) is not null Then
Cast((Select Top 1 FirstName,LastName From Person.Contact pc Where si.ContactID = pc.contactid ) As varchar)
Else ''
END
from Sales.Individual si
where si.CustomerID=11000
Modify the query
The erro is because you are choosing FirstName and LastName both so to remove erro choose one of them either firstanme or lastname or combine both in one
for example
this will resolve your issue
for more deatil check : Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.