Re: Group by minute

From: Mezei Zoltán <mezei(dot)zoltan(at)telefor(dot)hu>
To: Ezequias Rodrigues da Rocha <ezequias(dot)rocha(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Group by minute
Date: 2006-09-22 14:14:41
Message-ID: 4513EFD1.1010500@telefor.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000099">
Ezequias Rodrigues da Rocha wrote:
<blockquote
cite="mid55c095e90609220652t356c8591u412046aed091a52f(at)mail(dot)gmail(dot)com"
type="cite">Hil list,<br>
<br>
I have a query but my IDE (Delphi) does not accept "to_char"
capability. Is there a way to reproduce the same query without using
to_char function ?<br>
<br>
Here is my query:<br>
SELECT  to_char(quando,'dd/MM/yyyy HH24:MI'),count(id)
<br>
FROM base.tentativa<br>
WHERE  (SESSAO_ID = 15) <br>
GROUP BY to_char(quando,'dd/MM/yyyy HH24:MI')<br>
order by 1<br>
<br>
</blockquote>
That seems like a valid query in Oracle :-)<br>
<br>
Postgres have a slightly different mechanism for handling date and
time. The modified query:<br>
<br>
SELECT  date_trunc('minute', quando),count(id)
<br>
FROM base.tentativa<br>
WHERE  (SESSAO_ID = 15) <br>
-- GROUP BY to_char(quando,'dd/MM/yyyy HH24:MI')<br>
GROUP BY date_trunc('minute', quando)<br>
order by 1<br>
<br>
You should read:<br>
<a class="moz-txt-link-freetext" href="http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html">http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html</a><br>
<br>
Zizi<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.3 KB

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2006-09-22 14:56:02 Re: Group by minute
Previous Message Niklas Johansson 2006-09-22 14:10:54 Re: Group by minute