Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.


What I have tried:

SQL
Select
CASE
    WHEN 
		(SELECT subject_type FROM cdbwf_task
		WHERE cdbwf_task.cdb_process_id in (SELECT cdb_process_id
					FROM   cdbwf_process
					WHERE  EXISTS (SELECT cdb_process_id 
									FROM   cdbecm_briefcase2ec_v 
									WHERE  cdbwf_process.cdb_process_id = cdbecm_briefcase2ec_v.cdb_process_id)) AND status = 10) = 'Person' 
		THEN 
			(select personalnummer 
			 from angestellter 
			 where personalnummer in (
					   SELECT subject_id FROM cdbwf_task
					   WHERE cdbwf_task.cdb_process_id in (SELECT cdb_process_id
							FROM   cdbwf_process
							WHERE  EXISTS (SELECT cdb_process_id 
											FROM   cdbecm_briefcase2ec_v 
											WHERE  cdbwf_process.cdb_process_id = cdbecm_briefcase2ec_v.cdb_process_id)) AND status = 10))
	ELSE
		(select * 
		from cdbvp_resp_brows 
		where subject_id in (		
			SELECT subject_id FROM cdbwf_task
			WHERE cdbwf_task.cdb_process_id in (SELECT cdb_process_id
						FROM   cdbwf_process
						WHERE  EXISTS (SELECT cdb_process_id 
										FROM   cdbecm_briefcase2ec_v 
										WHERE  cdbwf_process.cdb_process_id = cdbecm_briefcase2ec_v.cdb_process_id)) AND status = 10))
	END
Posted
Updated 8-Jul-20 23:49pm
Comments
Andre Oosthuizen 9-Jul-20 3:24am    
THIS might help if not seen yet.

What the error is saying is that you can't include AND STATUS = 10 to your WHERE condition, because the SELECT list may return more than one row, and it has no idea which of them it should check against.

I'd start by executing each subquery independently and looking at what they are actually returning, then thinking about what I am trying to produce as a result here.

We can't do that for you - we have no idea what you are trying to achieve, or any access to your data!
 
Share this answer
 
Quote:
SQL
ELSE
    (select * 
    from cdbvp_resp_brows 
You're trying to select multiple columns as the value for a single column.

Replace select * with select COLUMN_NAME, specifying the name of the single column you want to return.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900