108 words, 1 min read
⚠️ This post links to an external website. ⚠️
Rather than adhering to alphabetical order, when using
order bywith an enum column, the sorting adheres to the order in which the values were listed when the enum was created.create type application_status as enum ( 'submitted', 'under_review', 'accepted', 'rejected' );create table applications ( applicant_name text, status application_status );insert into applications values ('George Washington', 'accepted'), ('John Adams', 'under_review'), ('Thomas Jefferson', 'under_review'), ('Aaron Burr', 'rejected'), ('Thomas Pinckney', 'submitted');select * from applications order by status; -- applicant_name | status -- ------------------+------------- -- Thomas Pinckney | submitted -- John Adams | under_review -- Thomas Jefferson | under_review -- George Washington | accepted -- Aaron Burr | rejected
continue reading on til.hashrocket.com
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.