Skip to content

Instantly share code, notes, and snippets.

@almeidaalex
Last active October 28, 2022 13:10
Show Gist options
  • Save almeidaalex/1f66ed47775c4f85fcf72d4fe38f457f to your computer and use it in GitHub Desktop.
Save almeidaalex/1f66ed47775c4f85fcf72d4fe38f457f to your computer and use it in GitHub Desktop.
group by month and year
select format(created_at, 'MM.yyyy') as created_at
, sum(tolerance) as t_sum
, sum(measured_value) as t_measure
from ncr_tickets as n
group by format(created_at, 'MM.yyyy')
Ncr::NcrTicket
.select("sum(tolerance) as tolerance, sum(measured_value) as measured_value, format(created_at, 'MM.yyyy') as created_at")
.group("format(created_at, 'MM.yyyy')")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment