parent
008455bc0c
commit
ef53b2a2de
|
@ -1882,6 +1882,16 @@ The `group by` clause looks quite similar to the `select` clause—it has a
|
|||
- if there's just one item, then the query will have a single result for each unique value of that item, or
|
||||
- if there are multiple items, the query will have a result for each unique _combination_ or their values.
|
||||
|
||||
The BNF for a grouped item is just:
|
||||
|
||||
[[hql-group-by-item-bnf]]
|
||||
====
|
||||
[source, antlrv4, indent=0]
|
||||
----
|
||||
include::{extrasdir}/group_by_item_bnf.txt[]
|
||||
----
|
||||
====
|
||||
|
||||
Consider the following queries:
|
||||
|
||||
[[hql-group-by-example]]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
identifier | INTEGER_LITERAL | expression
|
|
@ -1,11 +1,11 @@
|
|||
limitClause
|
||||
: LIMIT parameterOrIntegerLiteral
|
||||
: "LIMIT" parameterOrIntegerLiteral
|
||||
|
||||
offsetClause
|
||||
: OFFSET parameterOrIntegerLiteral (ROW | ROWS)?
|
||||
: "OFFSET" parameterOrIntegerLiteral ("ROW" | "ROWS")?
|
||||
|
||||
fetchClause
|
||||
: FETCH (FIRST | NEXT)
|
||||
(parameterOrIntegerLiteral | parameterOrNumberLiteral PERCENT)
|
||||
(ROW | ROWS)
|
||||
(ONLY | WITH TIES)
|
||||
: "FETCH" ("FIRST" | "NEXT")
|
||||
(parameterOrIntegerLiteral | parameterOrNumberLiteral "%")
|
||||
("ROW" | "ROWS")
|
||||
("ONLY" | "WITH" "TIES")
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
sortExpression orderingSpecification? nullsPrecedence?
|
||||
sortExpression sortDirection? nullsPrecedence?
|
||||
|
||||
sortExpression
|
||||
: identifier | INTEGER_LITERAL | expression
|
||||
|
||||
orderingSpecification
|
||||
: ASC | DESC
|
||||
sortDirection
|
||||
: "ASC" | "DESC"
|
||||
|
||||
nullsPrecedence
|
||||
: NULLS (FIRST | LAST)
|
||||
: "NULLS" ("FIRST" | "LAST")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
expression NOT? IN inList
|
||||
expression "NOT"? "IN" inList
|
||||
|
||||
inList
|
||||
: (ELEMENTS|INDICES) LEFT_PAREN dotIdentifierSequence RIGHT_PAREN
|
||||
| LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
|
||||
| LEFT_PAREN subquery RIGHT_PAREN
|
||||
: ("ELEMENTS"|"INDICES") "(" simplePath ")"
|
||||
| "(" (expression ("," expression)*)? ")"
|
||||
| "(" subquery ")"
|
||||
| parameter
|
||||
|
|
|
@ -1 +1 @@
|
|||
expression NOT? (LIKE | ILIKE) expression (ESCAPE character)?
|
||||
expression "NOT"? ("LIKE" | "ILIKE") expression ("ESCAPE" character)?
|
||||
|
|
|
@ -1 +1 @@
|
|||
CASE (WHEN predicate THEN expression)+ (ELSE expression)? END
|
||||
"CASE" ("WHEN" predicate "THEN" expression)+ ("ELSE" expression)? "END"
|
|
@ -1,7 +1,7 @@
|
|||
(expression | instantiation) alias?
|
||||
|
||||
instantiation
|
||||
: NEW instantiationTarget LEFT_PAREN instantiationArgs RIGHT_PAREN
|
||||
: "NEW" instantiationTarget "(" instantiationArguments ")"
|
||||
|
||||
alias
|
||||
: AS? IDENTIFIER
|
||||
: "AS"? IDENTIFIER
|
|
@ -1 +1 @@
|
|||
CASE expression (WHEN expression THEN expression)+ (ELSE expression)? END
|
||||
"CASE" expression ("WHEN" expression "THEN" expression)+ ("ELSE" expression)? END
|
|
@ -1 +1,2 @@
|
|||
deleteStatement : DELETE FROM? targetEntity whereClause?
|
||||
deleteStatement
|
||||
: "DELETE" "FROM"? targetEntity whereClause?
|
||||
|
|
|
@ -1 +1,14 @@
|
|||
insertStatement : INSERT INTO? targetEntity targetFields (queryExpression | valuesList)
|
||||
insertStatement
|
||||
: "INSERT" "INTO"? targetEntity targetFields (queryExpression | valuesList)
|
||||
|
||||
targetEntity
|
||||
: entityName variable?
|
||||
|
||||
targetFields
|
||||
: "(" simplePath ("," simplePath)* ")"
|
||||
|
||||
valuesList
|
||||
: "VALUES" values ("," values)*
|
||||
|
||||
values
|
||||
: "(" expression ("," expression)* ")"
|
||||
|
|
|
@ -5,7 +5,7 @@ queryExpression
|
|||
: orderedQuery (setOperator orderedQuery)*
|
||||
|
||||
orderedQuery
|
||||
: (query | LEFT_PAREN queryExpression RIGHT_PAREN) queryOrder?
|
||||
: (query | "(" queryExpression ")") queryOrder?
|
||||
|
||||
query
|
||||
: selectClause fromClause? whereClause? (groupByClause havingClause?)?
|
||||
|
|
|
@ -1 +1,11 @@
|
|||
updateStatement : UPDATE VERSIONED? targetEntity setClause whereClause?
|
||||
updateStatement
|
||||
: "UPDATE" "VERSIONED"? targetEntity setClause whereClause?
|
||||
|
||||
targetEntity
|
||||
: entityName variable?
|
||||
|
||||
setClause
|
||||
: "SET" assignment ("," assignment)*
|
||||
|
||||
assignment
|
||||
: simplePath "=" expression
|
||||
|
|
Loading…
Reference in New Issue