分析函数

ORDER BY中的分析函数

 ```1 2 3 4``` ```SELECT customer_id, customer_name, RANK(customer_id, customer_address DESC) FROM customer_t WHERE customer_state = 'CA' ORDER BY RANK(customer_id, customer_address DESC); ```

 ```1 2 3 4``` ```SELECT customer_id, customer_name, RANK() over(order by customer_id, customer_address DESC) FROM customer_t WHERE customer_state = 'CA' ORDER BY RANK() over(order by customer_id DESC, customer_address DESC) ; ```

 ```1 2 3 4 5 6 7``` ```SELECT customer_city, customer_state, postal_code , rank(postal_code) , rank() over(partition by customer_state order by postal_code) , rank() over(order by postal_code) FROM Customer_T GROUP BY customer_state ORDER BY customer_state; ```

 ```1 2 3 4 5 6``` ```SELECT customer_city, customer_state, postal_code , rank() over(PARTITION BY customer_state ORDER BY postal_code DESC) , rank() over(partition by customer_state order by postal_code) , rank() over(order by postal_code) FROM Customer_T ORDER BY customer_state; ```

PARTITION BY中的分析函数

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```SELECT Customer_id ,customer_name ,rank ( ) over( partition BY 1 ORDER BY Customer_id ) ,rank (customer_name) FROM Customer_t GROUP BY 1 ; ```

 ``` 1 2 3 4 5 6 7 8 9 10``` ```SELECT Customer_id ,customer_name ,rank ( ) over( partition BY 1 ORDER BY Customer_id ) ,rank ( ) over( PARTITION BY Customer_id ORDER BY customer_name DESC ) FROM Customer_t ; ```

*必选