Subject | RE: [firebird-support] Group by month based on a timestamp? |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-12-15T14:28:30Z |
>> I've got data in a table containing timestamps in a timestamp column. IOr, if you don't want to group November 2010 with November 2011:
>> 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)
select count(*)
, extract(year from mytimestamp) || '-' ||
extract(month from mytimestamp) as MyMonth
from t
group by 2, 3
HTH,
Set