SQL Concepts Question and Solution CTE Window Functions Types of Window functions Aggregate Window Functions SUM(), MAX(), MIN(), AVG(). COUNT() Ranking Window Functions RANK(), DENSE_RANK(), ROW_NUMBER(), NTILE() Value Window Functions LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE() ALL ALL is an optional keyword. When you will include ALL it will count all values including duplicate ones. DISTINCT is not supported in window functions ex: SELECT order_id , order_date , customer_name , city , order _ amount , MAX ( order_amount ) OVER ( PARTITION BY city ) as maximum_order_amount FROM [ dbo ] . [ Orders ] ex: 3 4 5 SELECT order_id , order_date , customer_name , city , order_amount , DENSE_RANK ( ) OVER ( ORDER BY order_amount DESC ) [ Rank ] FROM [ dbo ] . [ Orders ] ex: ROW_NUMBER() with PARTITION BY 1 2 3 4 5 SELECT order_id , order_date , customer_name , city , order_amount , ROW_NUMBER ( ) OVER ( PARTITION BY city ORDER BY order_amount DESC ) [ row_nu...