目录
===============================================
1.带空值的排列
2.Top/Bottom N查询
3.First/Last排名查询
4.按层次查询
一、带空值的排列:
在前面《Oracle开发专题之:分析函数2(Rank、Dense_rank、row_number)》一文中,我们已经知道了如何为一批记录进行全排列、分组排列。假如被排列的数据中含有空值呢?
SQL>?select?region_id,?customer_id,
??2?????????sum(customer_sales)?cust_sales,
??3?????????sum(sum(customer_sales))?over(partition?by?region_id)?ran_total,
??4?????????rank()?over(partition?by?region_id
??5??????????????????order?by?sum(customer_sales)?desc)?rank
??6????from?user_order
??7???group?by?region_id,?customer_id;
??2?????????sum(customer_sales)?cust_sales,
??3?????????sum(sum(customer_sales))?over(partition?by?region_id)?ran_total,
??4?????????rank()?over(partition?by?region_id
??5??????????????????order?by?sum(customer_sales)?desc)?rank
??6????from?user_order
??7???group?by?region_id,?customer_id;