Subject Re: [firebird-support] Group by month based on a timestamp?
Author Thomas Steinmaurer
> I've got data in a table containing timestamps in a timestamp column. I
> want to group these by month.
>
> How?
>
> Anything simpler/better than this:
> substring(cast(T."TheTimestamp" as varchar(50)) from 1 for 7)

select
count(*)
, extract(month from mytimestamp)
from
t
group by
extract(month from mytimestamp)

You can speed up things on a large table by adding an expression index.



HTH.


--
With regards,
Thomas Steinmaurer

* Upscene Productions - Database Tools for Developers
http://www.upscene.com/

* My Blog
http://blog.upscene.com/thomas/index.php

* Firebird Foundation Committee Member
http://www.firebirdsql.org/en/firebird-foundation/