add examples of :alias with :group-by
Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
parent
44ca426b78
commit
c295db44c0
2 changed files with 13 additions and 0 deletions
|
|
@ -1091,6 +1091,11 @@ user=> (sql/format '{select (*) from (table)
|
|||
["SELECT * FROM table GROUP BY status, YEAR(created_date)"]
|
||||
```
|
||||
|
||||
You can `GROUP BY` expressions, column names (`:col1`), or table and column (`:table.col1`),
|
||||
or aliases (`:some.alias`). Since there is ambiguity between the formatting
|
||||
of those, you can use the special syntax `[:alias :some.thing]` to tell
|
||||
HoneySQL to treat `:some.thing` as an alias instead of a table/column name.
|
||||
|
||||
## having
|
||||
|
||||
The `:having` clause works identically to `:where` above
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@ and strings.
|
|||
:from :b
|
||||
:order-by [[[:alias :'some-alias]]]})
|
||||
;;=> ["SELECT column_name AS \"some-alias\" FROM b ORDER BY \"some-alias\" ASC"]
|
||||
(sql/format {:select [[:column-name "some-alias"]]
|
||||
:from :b
|
||||
:group-by [[:alias "some-alias"]]})
|
||||
;;=> ["SELECT column_name AS \"some-alias\" FROM b GROUP BY \"some-alias\""]
|
||||
(sql/format {:select [[:column-name "some-alias"]]
|
||||
:from :b
|
||||
:group-by [[:alias :'some-alias]]})
|
||||
;;=> ["SELECT column_name AS \"some-alias\" FROM b GROUP BY \"some-alias\""]
|
||||
```
|
||||
|
||||
## array
|
||||
|
|
|
|||
Loading…
Reference in a new issue