On Thu, Aug 18, 2016 at 4:56 AM, <haman...@t-online.de> wrote: > select custid, count(vendid) as c415 from cv where vendid = 415 group by > custid > [...] > > Is there a better way (by creating an aggregate function, perhaps) >
You may find crosstab in the tablefuncs extension to be of use. https://www.postgresql.org/docs/current/static/tablefunc.html David J.