Re: sub select

Поиск
Список
Период
Сортировка
От Tod McQuillin
Тема Re: sub select
Дата
Msg-id 20010830212701.H28610-100000@glass.pun-pun.prv
обсуждение исходный текст
Ответ на sub select  ("Ben-Nes Michael" <miki@canaan.co.il>)
Список pgsql-general
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



В списке pgsql-general по дате отправления:

Предыдущее
От: "Andrew Snow"
Дата:
Сообщение: RE: MySQL treads belong else where.
Следующее
От: Andrew Sullivan
Дата:
Сообщение: --enable-syslog and Solaris 7