Logan
Logan

Reputation: 1371

Group by Multi Language Field

I am trying to find the users who are based on local language and English. As my data field contains both English and Local language.

ID  FULL_NAME
1   Logan
2   โลแกน
3   ซาเวียร์
4   Xavier

Is there a way to group something as following using SQL ?

english 2
other-lang 2

My database is really huge (should be more than 6M). So might need a very optimal solution.

Open for both MySQL/Oracle.

Upvotes: 1

Views: 39

Answers (1)

Mukesh Kalgude
Mukesh Kalgude

Reputation: 4844

Try this query

select 'English -' + convert(varchar(50),count(*)) from tablename where full_name like '[a-z]%'
union all
select 'Other Lang -' + convert(varchar(50), count(*) - (select count(*) from tablename where full_name like '[a-z]%')) from tablename

Upvotes: 1

Related Questions