Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Subquery Error

Author  Topic 

cwilli35
Starting Member

17 Posts

Posted - 2009-05-06 : 15:17:40
Can someone please tell me why I keep getting this error, after executing the following SQL?

"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS"

Select distinct C4 From ARRemedy_TEST.dbo.T10 Where C4 = (select distinct ARRemedy_TEST.dbo.T10.C1, ARRemedy_TEST.dbo.T33.C538000011, ARRemedy_TEST.dbo.T10.C4 AS Assigned_to, ARRemedy_TEST.dbo.T10.C538000109
FROM ARRemedy_TEST.dbo.T10, ARRemedy_TEST.dbo.T33
WHERE ARRemedy_TEST.dbo.T10.C538000030 =
ARRemedy_TEST.dbo.T33.C538000030 AND ARRemedy_TEST.dbo.T10.C1 = ARRemedy_TEST.dbo.T33.C538000245
and ARRemedy_TEST.dbo.T10.c538000109 != 'Closed')

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-06 : 15:26:43
Where C4 = (select distinct ...
You cannot compare C4 with a complete resultset.
You can compare C4 with only one value at a time.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

cwilli35
Starting Member

17 Posts

Posted - 2009-05-06 : 15:32:30
Thanks 'webfred' i'm a bit of a novice when it comes to SQL. Are you saying I'll need multiple subqueries?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-06 : 15:38:47
Fast answer is yes.
But slow answer has to be: Make your SELECT in another way.

I'm sorry because I have not the time to give you more advice in this moment.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

cwilli35
Starting Member

17 Posts

Posted - 2009-05-07 : 08:16:12
SOMEONE PLEASE HELP! I'm stumped right now.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-07 : 14:52:59
I read your post more than once but it is not clear what you want.
The only way to make it possible to help is:
Give (example) table structure.
Give sample data.
Give sample for wanted output in relation to sample data.

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -