sql 开窗函数
Posted 张小帅
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 开窗函数相关的知识,希望对你有一定的参考价值。
mysql 不支持 分组子查询 over;
SELECT SalesOrderID, ProductID, OrderQty
,SUM(OrderQty) OVER(PARTITION BY SalesOrderID) AS ‘Total‘
,AVG(OrderQty) OVER(PARTITION BY SalesOrderID) AS ‘Avg‘
,COUNT(OrderQty) OVER(PARTITION BY SalesOrderID) AS ‘Count‘
,MIN(OrderQty) OVER(PARTITION BY SalesOrderID) AS ‘Min‘
,MAX(OrderQty) OVER(PARTITION BY SalesOrderID) AS ‘Max‘
FROM SalesOrderDetail
WHERE SalesOrderID IN(43659,43664);
以上是关于sql 开窗函数的主要内容,如果未能解决你的问题,请参考以下文章