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
 General SQL Server Forums
 New to SQL Server Programming
 subquery needs to be introduced with EXIST?

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-02-22 : 10:46:30
Hi,

When running the following query I receive the message below,
any thanks in advance for your assistance.


select max(a.UserName),max(a.ReportName),sum(a.ReportCount) as rc from View_BIUsers_ReportData a
where UserName IN ( select * from D_BIUsers where bukey in (select BUKey from D_BusinessUnits where LEID = '02001' and SBLID = 'MKG'))
and Year = '2011'
and TreeYear = 2011
group by ReportName
order by rc desc



Msg 116, Level 16, State 1, Line 3
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-22 : 10:53:18
where UserName IN ( select * from
should be
where UserName IN ( select Column_that_holds_the_needed_Username from


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

tariq2
Posting Yak Master

125 Posts

Posted - 2011-02-22 : 11:09:48
thank you, resolved :)
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-22 : 11:54:44
welcome


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

- Advertisement -