On Sunday, February 18, 2018 at 12:15:21 PM UTC-8, Gencer W. G. wrote:
>
> Hi Jeremy,
>
> I have to count how many objects in the database by month. I am currently
> using this query (as raw):
>
> select count(*), date_trunc( 'month', created_on ) from objs group by
> date_trunc( 'month', created_on );
>
>
> Is there any helper in Sequel that helps me on grouping objects by month
> and retrieve the data? If no how can I properly write above statement in
> Sequel?
>
You can probably do what you want via:
DB[:objs].group_and_count{created_on.extract(:month)}
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.