Search Postgresql Archives

Re: extend "group by" to include "empty relations" ?

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

 



peter pilsl wrote:

> But there is a problem now: There are also entries in fn_kat which dont
> have corresponding entries in fn_dokumente and this entries should be
> listed too. With the proper count=0 !!

Your problem is not on the GROUP BY, but rather that you need an outer
join.  Try something like

 select k.kategorie,count(d.oid) from fn_kat k left join fn_dokumente d
 on k.id=d.kategorie group by k.kategorie;

-- 
Alvaro Herrera                               http://www.PlanetPostgreSQL.org/
"The first of April is the day we remember what we are
the other 364 days of the year"  (Mark Twain)

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[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