    {:pre  [(string? sql)]
     :post [(map? %)
            (vector? (:result %))]}
+    (let [group-by (get-group-by summarize-by)]
+      (validate-order-by! (event-counts-columns group-by) paging-options))
     (-> (execute-query (apply vector sql params) paging-options)
       (update-in [:result] (partial munge-subjects summarize-by)))))

  IllegalArgumentException is thrown."
  [summarize-by]
  {:pre  [(string? summarize-by)]
   :post [(string? %)]}
  (condp = summarize-by
    "certname" "certname"
    "containing-class" "containing_class"
    "resource" "resource_type, resource_title"
    (throw (IllegalArgumentException. (format "Unsupported value for 'summarize-by': '%s'" summarize-by)))))

(defn- get-counts-filter-where-clause

              SUM(CASE WHEN status = 'skipped' THEN 1 ELSE 0 END) AS skips
            FROM (%s) events
            GROUP BY %s"
          (string/join ", " group-by)
          event-sql
          (string/join ", " group-by)))

(defn- get-filtered-sql
  "Given a `sql` string and optional `where` clause, return the appropriate filtered
