Skip to content

Instantly share code, notes, and snippets.

@drsnyder
Created February 28, 2013 18:29
Show Gist options
  • Save drsnyder/5058938 to your computer and use it in GitHub Desktop.
Save drsnyder/5058938 to your computer and use it in GitHub Desktop.
Test for order by `col = val`
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