简体   繁体   中英

Select distinct first character based on the string column

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

这可能有效:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM