'GROUP BY' problem

Поиск
Список
Период
Сортировка
От Mariusz Czułada
Тема 'GROUP BY' problem
Дата
Msg-id 200301300923.50894.manieq@idea.net.pl
обсуждение исходный текст
Список pgsql-general
Hi all,

I have a table:

CREATE TABLE tmp_server_perf_sum (
    ts timestamp without time zone,
    lock_count double precision,
    cpu_busy_pct double precision,
    transactions_rate double precision,
    deadlock_count double precision
);

/* data from Sybase Historical Server */

I can:

SELECT
    date_trunc('hour',ts),
    min(cpu_busy_pct),
    avg(cpu_busy_pct),
    max(cpu_busy_pct)
FROM
    tmp_server_perf_sum
GROUP BY
    date_trunc('hour',ts);

and it works great. But 1h interval is to wide for me. On the over hand 1
minute is less than my samples in table. I'd like to group results for every
15 minues. I'd love to do it this way:

SELECT
    date_trunc('15 minutes',ts),
    min(cpu_busy_pct),
    avg(cpu_busy_pct),
    max(cpu_busy_pct)
FROM
    tmp_server_perf_sum
GROUP BY
    date_trunc('15 minutes',ts);

but unfortunately it is not working (I use 7.2.2, but IMHO it is not
important).

1. Can sb. help me with this query? How to make such groupping?

2. Do you think is it possible/needed to extend 'date_trunc' function to
support such options?

TIA

Mariusz Czulada


В списке pgsql-general по дате отправления:

Предыдущее
От: Holger Klawitter
Дата:
Сообщение: donations?
Следующее
От: Holger Klawitter
Дата:
Сообщение: Re: Firewalls and Postgres