Choose a great first character based on a row column

In SQLite, I have a contact table with one of the columns last_name. How can I get a unique set of first characters of all surnames in a table? Something like that ['a', 'b', 'd', 'f', 'w']. This will help if the request is case insensitive. I am using SQLite on Android. Thanks

+3
source share
1 answer

This might work:

SELECT DISTINCT lower(substr(last_name,1,1)) AS last_initial FROM my_table;
+10
source

Source: https://habr.com/ru/post/1791575/


All Articles