Drizzle TeamDT
Drizzle Team3y ago
9 replies
AstroBear

Why does `sum` return `SQL<string | null>`?

I was trying to use the
sum
aggregate function and I noticed that it returns a string. Why is that?
/**
 * Returns the sum of all non-null values in `expression`.
 *
 * ## Examples
 *
 * \`\`\`ts
 * // Sum of every employee's salary
 * db.select({ value: sum(employees.salary) }).from(employees)
 * \`\`\`
 *
 * @see sumDistinct to get the sum of all non-null and non-duplicate values in `expression`
 */
export declare function sum(expression: SQLWrapper): SQL<string | null>;
Was this page helpful?