Re: Understanding Aliases

From: "Harald Armin Massa" <haraldarminmassa(at)gmail(dot)com>
To: "Stanislav Raskin" <sr(at)brainswell(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Understanding Aliases
Date: 2007-12-11 18:17:30
Message-ID: 7be3f35d0712111017q5b04d8efhc129539c488494cb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2007-12-11 18:19:51 Re: top posting (was: Hijack!)
Previous Message Scott Marlowe 2007-12-11 18:00:00 Re: top posting (was: Hijack!)