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 as column

Author  Topic 

seanh1016
Starting Member

14 Posts

Posted - 2010-10-28 : 23:56:26
is there a glaring reason this should not work b/c I think it should yet it's not working. trying to simply add another columnB from the same tableB in my existing select "t" yet this time tableB has no joins. should I somehow join it to "t?" should the second select be in the FROM section instead? thanks.

select*,
columnB,
(
select
columnA, columnB
from tableB ---plus other joins
where...
) as t
from
tableB ---no other joins
where...

Devart
Posting Yak Master

102 Posts

Posted - 2010-10-29 : 02:10:08
Hello,

You can not use more than one column in such subquery.
If you want do it, you can use two subquery.
For example:
select*,
columnB,
(
select
columnA
from tableB ---plus other joins
where...
) as t1,
(
select
columnB
from tableB ---plus other joins
where...
) as t2
from
tableB ---no other joins
where...

But...

Best regards,

Devart,
SQL Server Tools:
dbForge Schema Compare
dbForge Data Compare
dbForge Query Builder
Go to Top of Page
   

- Advertisement -