Re: Understanding Aliases - Mailing list pgsql-general

From Harald Armin Massa
Subject Re: Understanding Aliases
Date
Msg-id 7be3f35d0712111017q5b04d8efhc129539c488494cb@mail.gmail.com
Whole thread Raw
In response to Re: Understanding Aliases  ("Stanislav Raskin" <sr@brainswell.de>)
Responses Re: Understanding Aliases
List 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 by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: top posting (was: Hijack!)
Next
From: Erik Jones
Date:
Subject: Re: top posting (was: Hijack!)