-
-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SELECT DISTINCT foo ON (bar) #1
Comments
Right now this isn't supported, but could be if a syntax for it can be worked out. One thought: create a new :select-distinct clause (see honeysql.format/format-clause) that takes two sets of fields: one for the "on" fields, and one for the other fields. E.g., {:select-distinct [[:bar] [:foo]]} or, with a helper defined: (select-distinct [:bar] [:foo]) |
Okay, that's helpful, thanks! |
you can do this now: (-> (select (sql/call :distinct-on :bar) :foo) (sql/format))
=> ["SELECT DISTINCT ON (bar), foo"] |
|
I was trying to generate a
SELECT DISTINCT ON (bar) foo
recently and the only mechanism I could figure out was:which feels like unintended usage, but at least works (at least because SQL isn't case-sensitive).
Is there a better way to do this, or a straightforward design as a new feature that I could add?
The text was updated successfully, but these errors were encountered: