mysql Select the sum of occurances of first alphabetical character -



mysql Select the sum of occurances of first alphabetical character -

hi need create select statement outputs sum of first character in field within table output like

a,12 b,0 c,20 d,14 e,0 ect...

the table called contacts, in above there 12 occurrences of people names begin letter , there 0 occurences of letter b.

i hope have explained correctly

in order result display missing letters, need manually generate letters (eg. using subquery)

select a.letter, count(u.name) totalcount ( select 'a' letter union select 'b' letter union select 'c' letter union -- until z select 'z' letter ) left bring together userlist u on a.letter = left(u.name, 1) -- <== column name grouping a.letter order a.letter

mysql

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -