pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: Need magical advice for counting NOTHING
Date: Thu, 23 Jul 2009 09:10:08 +0200
Message-ID: <20090723071007.GB28356@a-kretschmer.de> (raw)
In-Reply-To: <20090723065722.GA28356@a-kretschmer.de>
References: <4A67EEB2.1070302@gmx.net>
	<20090723065722.GA28356@a-kretschmer.de>

In response to A. Kretschmer :
> test=*# select foo.user_name, foo.log_type, sum(case when log_type_fk is
> not null then 1 else 0 end) from (select user_id, user_name,
> log_type_id, log_type from users cross join log_type) foo full join log
> on ((foo.user_id, foo.log_type_id)=(log.user_fk, log.log_type_fk)) group
> by 1,2 order by 1,2;
>  user_name | log_type | sum
> -----------+----------+-----
>  user1     | type1    |   1
>  user1     | type2    |   0
>  user2     | type1    |   0
>  user2     | type2    |   1
> (4 rows)

Update:

select foo.user_name, foo.log_type, count(log_type_fk) ...


-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net



view thread (7+ messages)  latest in thread

Message-ID: <20090723071007.GB28356@a-kretschmer.de>
Permalink:  ../20090723071007.GB28356@a-kretschmer.de/
Also on:    postgresql.org/message-id/20090723071007.GB28356@a-kretschmer.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andreas.kretschmer@schollglas.com
  Subject: Re: Need magical advice for counting NOTHING
  In-Reply-To: <20090723071007.GB28356@a-kretschmer.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox