阅读(4268)
赞(15)
Mycat2 Sql兼容性 窗口函数
2021-09-08 11:53:05 更新
v1.17提供
不涉及跨数据库的情况(即单表与全局表),Mycat的窗口函数使用方式与MySQL完全一致.
在涉及跨数据库的情况下,MycatWindow
不能下推变成SQL,所以在Mycat2内进行计算汇总结果.
语法
function OVER ([[partition by column1] [order by column2] [RANGE|ROWS BETWEEN start AND end]])
function OVER partition by column1 order by column2 RANGE BETWEEN start AND end
function OVER partition by column1 order by column2 ROWS BETWEEN start AND end
COUNT(value [, value ]*) OVER
COUNT(*) OVER
AVG(numeric) OVER
SUM(numeric) OVER
MAX(value) OVER
MIN(value) OVER
RANK() OVER
DENSE_RANK() OVER
ROW_NUMBER() OVER
FIRST_VALUE(value) OVER
LAST_VALUE(value) OVER
LEAD(value, offset, default) OVER
LAG(value, offset, default) OVER
NTILE(value) OVER
具体语义参考 https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html