SELECT dealer_id, emp_name, sales, ROW_NUMBER() OVER (PARTITIONBY dealer_id ORDERBY sales) AS rank, AVG(sales) OVER (PARTITIONBY dealer_id) AS avgsales FROM sales
# 上述查询中,rank 列表示在当前经销商下,该雇员的销售排名; # avgsales 表示当前经销商下所有雇员的平均销售额。查询结果如下 +------------+-----------------+--------+------+---------------+ | dealer_id | emp_name | sales | rank | avgsales | +------------+-----------------+--------+------+---------------+ |1| Raphael Hull |8227|1|14356| |1| Jack Salazar |9710|2|14356| |1| Ferris Brown |19745|3|14356| |1| Noel Meyer |19745|4|14356| |2| Haviva Montoya |9308|1|13924| |2| Beverly Lang |16233|2|13924| |2| Kameko French |16233|3|13924| |3| May Stout |9308|1|12368| |3| Abel Kim |12369|2|12368| |3| Ursa George |15427|3|12368| +------------+-----------------+--------+------+---------------+
select id, sq, cell_type, rank, row_number() over(partitionby id orderby rank ) naturl_rank, rank() over(partitionby id orderby rank) as r, dense_rank() over(partitionby cell_type orderby id) as dr from window_test_table groupby id,sq,cell_type,rank;
Checking if Disqus is accessible...