Re: Substring Problem - Mailing list pgsql-general

From Sam Mason
Subject Re: Substring Problem
Date
Msg-id 20080513135627.GA1657@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Substring Problem  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
List pgsql-general
On Tue, May 13, 2008 at 03:26:57PM +0200, Stefan Schwarzer wrote:
> SELECT substring(date from 1 for 7) AS stryearmonth, COUNT(id) AS
> countofnumber FROM (SELECT * from downloads ) AS foo GROUP BY
> stryearmonth ORDER BY stryearmonth ASC

Another way of doing this is by using date_trunc, i.e.:

  SELECT date_trunc('month',date) AS yearmonth...

I think it'll still realise it can use indexes (if they're appropriate)
that way.


  Sam

pgsql-general by date:

Previous
From: "IVO GELOV"
Date:
Subject: Strange behaviour - performance decreases after each TRUNCATE
Next
From:
Date:
Subject: Re: Substring Problem