Skip to content

Instantly share code, notes, and snippets.

@tagomoris
Created April 24, 2012 05:52
Show Gist options
  • Save tagomoris/2476903 to your computer and use it in GitHub Desktop.
Save tagomoris/2476903 to your computer and use it in GitHub Desktop.
(query
(fields (field yyyymmdd) (value (hash (parse_agent (field agent)) (string "category"))) (count *))
(from (table access_log))
(where
(and
(= (field service) (string "blog"))
(or
(= (field yyyymmdd) (string "20120331"))
(= (field yyyymmdd) (string "20120401"))
(= (value (hash (parse_agent (field agent)) (string "category"))) (string "smartphone")))))
(aggregate
(group (field yyyymmdd) (value (hash (parse_agent (field agent)) (string "category"))))
(order (asc (field yyyymmdd)) (desc (count *)))
(limit 30)))
;; (count *)
;; (count (field hoge))
;; (count (is_smartphone(parse_agent(agent))))
;; (count (if (= (field status) 500) 1 NULL))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment