Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds support for GROUP BY in SELECT

  • Loading branch information...
commit c5db7a111c7c4484720d6886073bdd267f6fe2ab 1 parent a33294e
@yrashk authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/queries/select.ex
View
9 lib/queries/select.ex
@@ -28,9 +28,16 @@ defrecord ExQL.Select, [fields: :*,
end
end
+ def statement(:group, query) do
+ case group(query) do
+ [] -> nil
+ group_by -> ["GROUP BY", ExQL.Expression.join(group_by, :raw, ", ")]
+ end
+ end
+
def statement(query) do
ExQL.Utils.space(
["SELECT", statement(:modifiers, query), statement(:fields, query),
- statement(:from, query), statement(:where, query)])
+ statement(:from, query), statement(:where, query), statement(:group, query)])
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.