mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Support for the TOTAL SQL aggregate function
This commit is contained in:
1 parent
8ba89a398a
commit
ae609cec3b
7 files changed
+149
-2
No files matched your search
@@ -101,6 +101,10 @@ public func min(_ value: SQLSpecificExpressible) -> SQLExpression {
|
||||
|
||||
/// Returns an expression that evaluates the `SUM` SQL function.
|
||||
///
|
||||
/// See <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
|
||||
///
|
||||
/// See also `total(_:)`.
|
||||
///
|
||||
/// // SUM(amount)
|
||||
/// sum(Column("amount"))
|
||||
public func sum(_ value: SQLSpecificExpressible) -> SQLExpression {
|
||||
@@ -108,6 +112,21 @@ public func sum(_ value: SQLSpecificExpressible) -> SQLExpression {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - TOTAL(...)
|
||||
|
||||
/// Returns an expression that evaluates the `TOTAL` SQL function.
|
||||
///
|
||||
/// See <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
|
||||
///
|
||||
/// See also `sum(_:)`.
|
||||
///
|
||||
/// // TOTAL(amount)
|
||||
/// total(Column("amount"))
|
||||
public func total(_ value: SQLSpecificExpressible) -> SQLExpression {
|
||||
.aggregate("TOTAL", [value.sqlExpression])
|
||||
}
|
||||
|
||||
|
||||
// MARK: - String functions
|
||||
|
||||
/// :nodoc:
|
||||
|
||||
Reference in new issue
Block a user