row number example

Solutions on MaxInterview for row number example by the best coders in the world

showing results for - "row number example"
Fabiana
18 Jun 2019
1
2            
3                
4            
5         WITH cte_customers AS (
6    SELECT 
7        ROW_NUMBER() OVER(
8             ORDER BY 
9                first_name, 
10                last_name
11        ) row_num, 
12        customer_id, 
13        first_name, 
14        last_name
15     FROM 
16        sales.customers
17) SELECT 
18    customer_id, 
19    first_name, 
20    last_name
21FROM 
22    cte_customers
23WHERE 
24    row_num > 20 AND 
25    row_num <= 30;
26Code language: SQL (Structured Query Language) (sql)
Nicole
29 Jul 2020
1
2            
3                
4            
5         SELECT 
6   first_name, 
7   last_name, 
8   city,
9   ROW_NUMBER() OVER (
10      PARTITION BY city
11      ORDER BY first_name
12   ) row_num
13FROM 
14   sales.customers
15ORDER BY 
16   city;Code language: SQL (Structured Query Language) (sql)