Re: Understanding Aliases

Поиск
Список
Период
Сортировка
От Harald Armin Massa
Тема Re: Understanding Aliases
Дата
Msg-id 7be3f35d0712111017q5b04d8efhc129539c488494cb@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Understanding Aliases  ("Stanislav Raskin" <sr@brainswell.de>)
Ответы Re: Understanding Aliases
Список pgsql-general
Stanislav,

SELECT
            t2.id,
               (SELECT COUNT(id) FROM t4 WHERE t2_id = t2.id AND value=10)
AS t4_num
FROM
               t2
WHERE
               t2.active
           AND (
(SELECT COUNT(id) FROM t4 WHERE t2_id = t2.id AND value=10) <= 3
               )


select
    t2.id, count( t4.id)
from
   t2 join t4 using on (t2.id=t4.t2_id)
where
   t2.active and t4.value < 10
group by t2.id
having count(t4.id) <= 3

should do the trick without double select, or?

Harald


--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!

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

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: top posting (was: Hijack!)
Следующее
От: Erik Jones
Дата:
Сообщение: Re: top posting (was: Hijack!)