X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6A3553B6D23 for ; Thu, 16 Dec 2004 10:34:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98026-02 for ; Thu, 16 Dec 2004 10:34:45 +0000 (GMT) Received: from foradada.isolaweb.it (unknown [80.247.74.2]) by svr1.postgresql.org (Postfix) with ESMTP id A4C443B6D54 for ; Thu, 16 Dec 2004 10:34:46 +0000 (GMT) Received: from ROBERTO.tekno-soft.it (ppp-217-133-165-5.cust-adsl.tiscali.it [217.133.165.5]) by foradada.isolaweb.it (8.12.8/linuxconf) with ESMTP id iBGAUCt7032766 for ; Thu, 16 Dec 2004 11:30:12 +0100 Message-Id: <6.2.0.14.2.20041216110510.07500100@mail.isolaweb.it> X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.14 Date: Thu, 16 Dec 2004 11:34:33 +0100 To: pgsql-sql@postgresql.org From: Roberto Fichera Subject: Query aid Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-IsolaWEB-MailScanner-Information: Please contact the ISP for more information X-IsolaWEB-MailScanner: Found to be clean X-MailScanner-From: kernel@tekno-soft.it X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/100 X-Sequence-Number: 19720 Hi all, I have a table acct as (username, terminatedate, terminatecause) I would like to build a query which returns three columns orderd by data like: date_trunc( 'day', terminatedate ) | count(cause1) | count(cause2) where cause1/2 are two type of termination cause from the field terminatecause. for example acct table could be: user1|01/01/2004 01:01:01| error user2|01/01/2004 01:02:01| error user1|01/01/2004 02:00:01| normal user3|02/01/2004 10:00:01| normal user2|02/01/2004 10:10:01| error I would like to obtain: date |normal| error 01/01/2004| 1 | 2 02/01/2004| 1 | 1 Thanks in advance. Roberto Fichera.