Help with query

From: Vegeta <vegeta(at)cuaima(dot)ica(dot)luz(dot)ve>
To: pgsql-general(at)postgresql(dot)org
Subject: Help with query
Date: 1999-11-05 13:35:25
Message-ID: Pine.LNX.4.05.9911050934530.27587-100000@cuaima.ica.luz.ve
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear list members:

I am new to the list and to SQL. I am using PostgreSQL 6.4.2 on Linux and
want to do the following query:
Given a table "works" with fields "idworker" (int4) and "timeofwork"
(datetime), i want to have a query who has the number of hours worked by
each "worker" in the form:
idworker hoursworked

I tried with:
SELECT idworker, COUNT(DISTINCT int8(timeofwork)/3600) as hoursworked
FROM works
GROUP BY idworker

but pgsql does not accept the DISTINCT inside the count (I read in a book
that there are some RDBMS that do accept it).
Is there another way to acomplish this?
Do I need to create a user-defined aggregate? If so, how should I do it?

Thanks in advance,
Guido Urdaneta

PS: Sorry for my bad english

Browse pgsql-general by date

  From Date Subject
Next Message Vegeta 1999-11-05 13:45:52 [GENERAL] Help with query (fwd)
Previous Message Ian Preedy 1999-11-05 09:22:37 - No Subject -