Subject Re: [firebird-support] Finding out dates from set of timestamp
Author Teträm Corp
Hi,

I guess you can do this by using an index on your field

Thierry

Harriv a écrit :
>
> On Tue, Mar 17, 2009 at 3:32 PM, Helen Borrie <helebor@...
> <mailto:helebor%40iinet.net.au>> wrote:
> > At 12:27 AM 18/03/2009, you wrote:
> >>Hi,
> >>
> >> Is there query to do following without going thru all the records
> in the
> >> table:
> >>
> >>select extract(YEAR FROM FIELD_TIMESTAMP),
> >>extract(MONTH FROM FIELD_TIMESTAMP),
> >>extract(DAY FROM FIELD_TIMESTAMP) from MYTABLE
> >>group by extract(YEAR FROM FIELD_TIMESTAMP),
> >>extract(MONTH FROM FIELD_TIMESTAMP),
> >>extract(DAY FROM FIELD_TIMESTAMP)
> >>
> >> So basically I need all the dates in the table, omitting the time
> >>part of timestamp.
> >>
> >> I'm using Firebird 1.5 in this.
> >
> > select cast (field_timestamp as date),
> > ..., ...
> > group by 1
>
> Yes, this gives the data in correct format (which is nice), but still
> scans thru whole table? Is it possible to avoid that?
>
> >
> > ./hb
> >
> >>------------------------------------
> >>
> >>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>
> >>Visit http://www.firebirdsql.org <http://www.firebirdsql.org> and
> click the Resources item
> >>on the main (top) menu. Try Knowledgebase and FAQ links !
> >>
> >>Also search the knowledgebases at http://www.ibphoenix.com
> <http://www.ibphoenix.com>
> >>
> >>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>Yahoo! Groups Links
> >>
> >>
> >>
> >
>
>