Open agershun opened 9 years ago
One more crazy idea to extend SQL: I am thinking about two different operators: LET and BEGIN (like in the question from StackOverflow).
LET will work before WHERE (wherefn()) and BEGIN will work right before or right after SELECT(selectfn()/groupfn()) like:
SET @c = 0;
SELECT a, @b, @c
FROM one
LET @b = a*a // internal variable only for current line
WHERE @b > 10
BEGIN SET @c = @c + a END; // own accumulator for selected lines
or call external procedure for each selected line:
alasql.fn.myfn = function (r) {
alasql.vars.b = r.default.a*r.default.a
};
alasql('SELECT a, @b FROM one LET myfn() WHERE @b > 10 ');
Like:
Source
This cluse will be calculated right before
wherefn()
andselectfn()
( orgroupfn()
).