From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Vegeta <vegeta(at)cuaima(dot)ica(dot)luz(dot)ve> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] Help with query (fwd) |
Date: | 1999-11-06 14:36:43 |
Message-ID: | Pine.LNX.4.20.9911061529150.347-100000@peter-e.yi.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 1999-11-05, Vegeta mentioned:
> 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
That query doesn't make much sense to me. I think what you meant was
something like this:
SELECT idworker, SUM(int8(timeofwork)/3600) FROM works GROUP BY idworker
I'm not sure about the appropriateness of your attempted typecast there,
though.
The timeofwork column should most likely be a timespan field. You can then
fill it with values like '5 hours 45 minutes'. Then your query could be:
SELECT idworker, SUM(date_part('epoch', timeofwork) * 3600) FROM works
GROUP BY idworker
--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 1999-11-06 14:48:59 | Re: [SQL] calulating with money type impossible ? |
Previous Message | Peter Eisentraut | 1999-11-06 14:22:11 | Re: Indices (was Re: [GENERAL] query seems too slow) |