UNPKG

@abaplint/core

Version:
22 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SQLAggregation = void 0; const combi_1 = require("../combi"); const tokens_1 = require("../../1_lexer/tokens"); const _1 = require("."); const dynamic_1 = require("./dynamic"); const sql_arithmetics_1 = require("./sql_arithmetics"); class SQLAggregation extends combi_1.Expression { getRunnable() { const f = (0, combi_1.seq)((0, combi_1.optPrio)("DISTINCT"), (0, combi_1.altPrio)(_1.SQLCase, sql_arithmetics_1.SQLArithmetics, dynamic_1.Dynamic, _1.SQLFunction)); const fparen = (0, combi_1.seq)("(", _1.Field, ")"); const count = (0, combi_1.seq)("COUNT", (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenLeft), (0, combi_1.tok)(tokens_1.ParenLeftW)), (0, combi_1.optPrio)("DISTINCT"), (0, combi_1.altPrio)("*", _1.Field, fparen), ")"); const max = (0, combi_1.seq)("MAX", (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenLeft), (0, combi_1.tok)(tokens_1.ParenLeftW)), f, ")"); const min = (0, combi_1.seq)("MIN", (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenLeft), (0, combi_1.tok)(tokens_1.ParenLeftW)), f, ")"); const sum = (0, combi_1.seq)("SUM", (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenLeft), (0, combi_1.tok)(tokens_1.ParenLeftW)), f, ")"); const avg = (0, combi_1.seq)("AVG", (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenLeft), (0, combi_1.tok)(tokens_1.ParenLeftW)), f, ")"); return (0, combi_1.altPrio)(count, max, min, sum, avg); } } exports.SQLAggregation = SQLAggregation; //# sourceMappingURL=sql_aggregation.js.map