SQL
Examples
Generate a `row_number` column with containing incremental identifiers for each row:  
```sql
SELECT row_number() OVER ()
FROM sales;
```  
Generate a `row_number` column, by order of time:  
```sql
SELECT row_number() OVER (ORDER BY time)
FROM sales;
```  
Generate a `row_number` column, by order of time partitioned by region:  
```sql
SELECT row_number() OVER (PARTITION BY region ORDER BY time)
FROM sales;
```  
Compute the difference between the current amount, and the previous amount, by order of time:  
```sql
SELECT amount - lag(amount) OVER (ORDER BY time)
FROM sales;
```  
Compute the percentage of the total amount of sales per region for each row:  
```sql
SELECT amount / sum(amount) OVER (PARTITION BY region)
FROM sales;
```