In SQLite I have a table of contacts with one of the columns being last_name
. How can I get unique set of first characters of all last names in the table? Something like ['a', 'b', 'd', 'f', 'w']
. It would help if query would be case insensitive. I'm using SQLite on Android. Thanks
This might work:
SELECT DISTINCT lower(substr(last_name,1,1)) AS last_initial FROM my_table;