SQL
Examples
All examples use this example table:  
```sql
CREATE OR REPLACE TABLE addresses AS
SELECT '123 Quack Blvd' AS address, 'DuckTown' AS city, '11111' AS zip
UNION ALL
SELECT '111 Duck Duck Goose Ln', 'DuckTown', '11111'
UNION ALL
SELECT '111 Duck Duck Goose Ln', 'Duck Town', '11111'
UNION ALL
SELECT '111 Duck Duck Goose Ln', 'Duck Town', '11111-0001';
```  
Select the addresses, ordered by city name using the default null order and default order:  
```sql
SELECT *
FROM addresses
ORDER BY city;
```  
Select the addresses, ordered by city name in descending order with nulls at the end:  
```sql
SELECT *
FROM addresses
ORDER BY city DESC NULLS LAST;
```  
Order by city and then by zip code, both using the default orderings:  
```sql
SELECT *
FROM addresses
ORDER BY city, zip;
```  
Order by city using German collation rules:  
```sql
SELECT *
FROM addresses
ORDER BY city COLLATE DE;
```  
#### `ORDER BY ALL` Examples {#docs:sql:query_syntax:orderby::order-by-all-examples}  
Order from left to right (by address, then by city, then by zip) in ascending order:  
```sql
SELECT *
FROM addresses
ORDER BY ALL;
```  
<div class="narrow_table"></div>  
|        address         |   city    |    zip     |
|------------------------|-----------|------------|
| 111 Duck Duck Goose Ln | Duck Town | 11111      |
| 111 Duck Duck Goose Ln | Duck Town | 11111-0001 |
| 111 Duck Duck Goose Ln | DuckTown  | 11111      |
| 123 Quack Blvd         | DuckTown  | 11111      |  
Order from left to right (by address, then by city, then by zip) in descending order:  
```sql
SELECT *
FROM addresses
ORDER BY ALL DESC;
```  
<div class="narrow_table"></div>  
|        address         |   city    |    zip     |
|------------------------|-----------|------------|
| 123 Quack Blvd         | DuckTown  | 11111      |
| 111 Duck Duck Goose Ln | DuckTown  | 11111      |
| 111 Duck Duck Goose Ln | Duck Town | 11111-0001 |
| 111 Duck Duck Goose Ln | Duck Town | 11111      |