Skip to content

Instantly share code, notes, and snippets.

@uded
Created September 5, 2013 20:19
Show Gist options
  • Save uded/6455599 to your computer and use it in GitHub Desktop.
Save uded/6455599 to your computer and use it in GitHub Desktop.
SELECT
DATE_FORMAT(date_value, '{{ groupby }}') AS date_value,
SUM(values) AS sum
FROM
table
GROUP BY
date_value
VARIABLE: {
name: "groupby",
display: "Aggregate by",
type: "select",
options: [
{display: "Day", value: "%Y-%m-%d"},
{display: "Calendar Week", value: "%Y CW %u"},
{display: "Month", value: "%Y %M"}],
default: "Calendar Week"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment