Amazon Redshift
数据库开发人员指南 (API Version 2012-12-01)
AWS 服务或AWS文档中描述的功能,可能因地区/位置而异。点 击 Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

MEDIAN 开窗函数示例

以下示例计算每个卖家的平均销售数量:

Copy
select sellerid, qty, median(qty) over (partition by sellerid) from winsales order by sellerid; sellerid qty median --------------------------- 1 10 10.0 1 10 10.0 1 30 10.0 2 20 20.0 2 20 20.0 3 10 17.5 3 15 17.5 3 20 17.5 3 30 17.5 4 10 25.0 4 40 25.0

有关 WINSALES 表的说明,请参阅开窗函数示例