Select query without duplicate "First letter" in sqlite

How can I select data without duplicating the value of the "First letter"? My table has a column called "title_raw" with data that follows "A, B, C, ..." I want my data to display something like this.

Select (title_raw no duplicate first letter) from SONGS
+3
source share
2 answers
SELECT DISTINCT substr(title_raw, 1, 1) FROM SONGS
+9
source
select substr(col, 0, 1) as Letter, count(primary_key) as Frequency
from table
group by Letter

I don't know if you can use the alias of the columns in the group using SQLite. This will give you any first letters that are unique. Then use this as a subquery for:

select data
from table
where substr(data, 0, 1) IN (subquery)

This should work

+1
source

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


All Articles