CCing to the list ( if you are new to this list, messages come from the sender address, you have to use "reply all" ( at least in my MUA, web gmail ) to make your replies appear in the list ). On Thu, Aug 18, 2016 at 3:03 PM, <hamann.w@xxxxxxxxxxx> wrote: > Hi Francisco, > thanks a lot. I will give it a try later Do it, and do not forget to try the straightforward solution ( sume of cases ) given by Ladislav Lenart above.I normally prefer to do this kind of things the way I pointed you because the queries are simpler and normally only the first one takes time, and using count tends to be the faster way to extract the relevant data ( the rest of my query, after the first with, is just moving data around for pretty-printing ( or pretty-selecting ). Francisco Olarte. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general