Subject Re: [ib-support] GROUP BY ON MONTH or YEAR of DATE FIELDS
Author Milan Babuskov
enricorav wrote:
> Hi to all,
> there are some methods for make a SELECT with GROUP BY on a part of a
> DATE or TIMESTAMP fields?
> Something like this:
>
> SELECT ...
> FROM MY_TABLE
> ...
> GROUP BY MONTH(DATE_REG), YEAR(DATE_REG)
>
> where DATE_REG are a DATE fields or TIMESTAMP fields ?

You can use some MONTH() and YEAR() UDFs, and group by it, or write a
view that uses EXTRACT like this:

CREATE VIEW v1
AS
SELECT extract(month from rate_reg), extract(year from date_reg), ...
from my_table;

Later you select from that view and group by this new fields.

HTH

Milan Babuskov
http://fbexport.sourceforge.net