moar tables
This commit is contained in:
parent
a61ffbfea7
commit
9edcf6b0c0
|
@ -1624,26 +1624,27 @@ It's no longer necessary to remove duplicate results explicitly, and `distinct`
|
||||||
It's common to have aggregate functions like `count()`, `sum()`, and `max()` in a select list.
|
It's common to have aggregate functions like `count()`, `sum()`, and `max()` in a select list.
|
||||||
Aggregate functions are special functions that reduce the size of the result set.
|
Aggregate functions are special functions that reduce the size of the result set.
|
||||||
|
|
||||||
|===
|
The standard aggregate functions defined in both ANSI SQL and JPQL are:
|
||||||
| Aggregate function | Result type
|
|
||||||
|
|
||||||
| `count()`, including `count(distinct)`, `count(all)`, and `count(*)` | `Long`
|
|===
|
||||||
| `avg()` | `Double`
|
| Aggregate function | Argument type | Result type
|
||||||
| `min()` | Same as the argument type
|
|
||||||
| `max()` | Same as the argument type
|
| `count()`, including `count(distinct)`, `count(all)`, and `count(*)` | Any | `Long`
|
||||||
| `sum()` | Depends on the type of the values being summed
|
| `avg()` | Any numeric type | `Double`
|
||||||
| `any()` | `Boolean`
|
| `min()` | Any numeric type, or string | Same as the argument type
|
||||||
| `every()` | `Boolean`
|
| `max()` | Any numeric type, or string | Same as the argument type
|
||||||
|
| `sum()` | Any numeric type | See table below
|
||||||
|===
|
|===
|
||||||
|
|
||||||
In the case of `sum()`:
|
In the case of `sum()`, the rules for assigning a result type are:
|
||||||
|
|===
|
||||||
|
| Argument type | Result type
|
||||||
|
|
||||||
* For integral values (other than `BigInteger`), the result type is `Long`.
|
| Any integral numeric type except `BigInteger` | `Long`
|
||||||
* For floating point values (other than `BigDecimal`) the result type is `Double`.
|
| Any floating point numeric type | `Double`
|
||||||
* For `BigInteger` values, the result type is `BigInteger`.
|
| `BigInteger` | `BigInteger`
|
||||||
* For `BigDecimal` values, the result type is `BigDecimal`.
|
| `BigDecimal` | `BigDecimal`
|
||||||
|
|===
|
||||||
Aggregate functions often appear in queries with a `group by` clause, as described <<hql-group-by,below>>.
|
|
||||||
|
|
||||||
[[hql-aggregate-functions-example]]
|
[[hql-aggregate-functions-example]]
|
||||||
//.Aggregate function examples
|
//.Aggregate function examples
|
||||||
|
@ -1654,6 +1655,17 @@ include::{sourcedir}/HQLTest.java[tags=hql-aggregate-functions-example]
|
||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
|
HQL defines the two additional aggregate functions which accept a logical predicate as an argument, for example, `every(p.amount < 1000.0)`.
|
||||||
|
|
||||||
|
|===
|
||||||
|
| Aggregate function | Argument type | Result type
|
||||||
|
|
||||||
|
| `any()` | Logical predicate | `Boolean`
|
||||||
|
| `every()` | Logical predicate | `Boolean`
|
||||||
|
|===
|
||||||
|
|
||||||
|
Aggregate functions often appear in queries with a `group by` clause, as described <<hql-group-by,below>>.
|
||||||
|
|
||||||
[[hql-aggregate-functions-filter]]
|
[[hql-aggregate-functions-filter]]
|
||||||
==== `filter`
|
==== `filter`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue