Thread: sub select

sub select

From
"Ben-Nes Michael"
Date:
Can I:

select *, sum_rows as ( select count(*) from table2; ) from table1;

--------------------------
Canaan Surfing Ltd.
Internet Service Providers
Ben-Nes Michael - Manager
Tel: 972-4-6991122
http://sites.canaan.co.il
--------------------------



Re: sub select

From
Tod McQuillin
Date:
On Thu, 30 Aug 2001, Ben-Nes Michael wrote:

> Can I:
>
> select *, sum_rows as ( select count(*) from table2; ) from table1;

I think you need to say:

select *, (select count(*) from table2) as sum_rows from table1;

But this won't be a very interesting query because the sum_rows column
will be the same in every row.

Where subselects get interesting is when you do a correlated subquery like
this:

select *, (select count(*) from table2 where table2.x = table1.y) as
sum_rows from table1;

--
Tod McQuillin