码迷,mamicode.com
首页 > 数据库 > 详细

sql 开窗函数

时间:2016-05-20 13:07:54      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:

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 开窗函数

标签:

原文地址:http://www.cnblogs.com/zhangxiaoshuai/p/5511554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!