How to use SQL Order By statement to sort results case insensitive? How to use SQL Order By statement to sort results case insensitive? sqlite sqlite

How to use SQL Order By statement to sort results case insensitive?


You can also do ORDER BY TITLE COLLATE NOCASE.

Edit: If you need to specify ASC or DESC, add this after NOCASE like

ORDER BY TITLE COLLATE NOCASE ASC

or

ORDER BY TITLE COLLATE NOCASE DESC


You can just convert everything to lowercase for the purposes of sorting:

SELECT * FROM NOTES ORDER BY LOWER(title);

If you want to make sure that the uppercase ones still end up ahead of the lowercase ones, just add that as a secondary sort:

SELECT * FROM NOTES ORDER BY LOWER(title), title;


SELECT * FROM NOTES ORDER BY UPPER(title)