Created
February 28, 2013 18:29
-
-
Save drsnyder/5058938 to your computer and use it in GitHub Desktop.
Test for order by `col = val`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BEGIN; | |
| CREATE TABLE order_by_test ( | |
| id SERIAL PRIMARY KEY, | |
| token INTEGER NOT NULL | |
| ); | |
| INSERT INTO order_by_test(token) | |
| SELECT id | |
| FROM generate_series(1,10) AS id; | |
| SELECT * | |
| FROM order_by_test | |
| ORDER BY token = 10 DESC, token = 9 DESC; | |
| ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment