Search Postgresql Archives

Re: Understanding Aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux