Comments - Aggregate Functions as Window Functions

8 years ago Brian DeMilia

Is there an issue of some sort when omitting the partition by clause in the over by, when using aggregate functions as analytic functions? (re: version 10.2.0 alpha)

This partition by is not a requirement in other databases. It is often very useful to have an over clause that is blank () so as to count or sum across the whole result set. This avoids having to join into an inline view that computes the same thing. It's the only way to calculate what ratio_to_report would in Oracle (without added subqueries).

For example, this does not seem to run at all: select x.*, count(x) over() as tot_rows from( select 1 as x union all select 2 ) x

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.