Jump to content

Recommended Posts

Posted

Since my time on here I have taken way more than I have given.  Today I was in search of a way to sort my tables alphabetically but without articles.  For example, I want "The Addams Family" to be sorted as "Addams Family" and not by using the T.  Although this may be common knowledge to others it was not for me.  Additionally, I was too lazy to change the GameDisplay value for the tables in question.  I was able to use this SQL to get me what I was after.  I am hopeful it is useful to others.

 

SELECT * 
FROM Games 
ORDER BY (CASE 
    WHEN GameDisplay LIKE 'the %' THEN substr(GameDisplay,5) 
    WHEN GameDisplay LIKE 'a %' THEN substr(GameDisplay,3) 
    WHEN GameDisplay LIKE 'an %' THEN substr(GameDisplay ,4) 
    ELSE GameDisplay END)

 

Good luck!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...