Hi,
I have quick question regarding behaviour of ORDER BY clause in SELECT statement. If I choose to order by a particular field, and there are several rows with same value for that field how are they ordered? Do they appear as in their relative order for the result set without the order by clause?
e.g. suppose "SELECT * FROM my_table" returns:
| col1 | col2 | col3 |
| a | A | 1 |
| b | B | 2 |
| c | C | 2 |
| d | D | 2 |
| e | E | 0 |
If I use the query "SELECT * FROM my_table ORDER BY col3" am I always certain to get:
| col1 | col2 | col3 |
| e | E | 0 |
| a | A | 1 |
| b | B | 2 |
| c | C | 2 |
| d | D | 2 |
and not say:
| col1 | col2 | col3 |
| e | E | 0 |
| a | A | 1 |
| b | B | 2 |
| d | D | 2 |
| c | C | 2 |
I've run simple tests and that seems to be the case, but I've yet to find any documentation that states this explicitly, so answers welcome!
Thanks,
Seosamh
I have quick question regarding behaviour of ORDER BY clause in SELECT statement. If I choose to order by a particular field, and there are several rows with same value for that field how are they ordered? Do they appear as in their relative order for the result set without the order by clause?
e.g. suppose "SELECT * FROM my_table" returns:
| col1 | col2 | col3 |
| a | A | 1 |
| b | B | 2 |
| c | C | 2 |
| d | D | 2 |
| e | E | 0 |
If I use the query "SELECT * FROM my_table ORDER BY col3" am I always certain to get:
| col1 | col2 | col3 |
| e | E | 0 |
| a | A | 1 |
| b | B | 2 |
| c | C | 2 |
| d | D | 2 |
and not say:
| col1 | col2 | col3 |
| e | E | 0 |
| a | A | 1 |
| b | B | 2 |
| d | D | 2 |
| c | C | 2 |
I've run simple tests and that seems to be the case, but I've yet to find any documentation that states this explicitly, so answers welcome!
Thanks,
Seosamh