Skip site navigation (1) Skip section navigation (2)

Query aid

From: Roberto Fichera <kernel(at)tekno-soft(dot)it>
To: pgsql-sql(at)postgresql(dot)org
Subject: Query aid
Date: 2004-12-16 10:34:33
Message-ID: 6.2.0.14.2.20041216110510.07500100@mail.isolaweb.it (view raw or flat)
Thread:
Lists: pgsql-sql
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. 


Responses

pgsql-sql by date

Next:From: Jerome AletDate: 2004-12-16 10:41:54
Subject: question about index
Previous:From: Andrew - SupernewsDate: 2004-12-16 03:37:56
Subject: Re: Breadth first traversal in PLSQL (How to implement Queue?)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group