我的名字看起来像这样:
我想做一个查询,找出有多少记录以An,Ar,Ba开头。 e.g。
答案 0 :(得分:9)
Select COUNT(*),SUBSTRING(column_name,1,2) FROM table_name GROUP BY SUBSTRING(column_name,1,2)
答案 1 :(得分:2)
SELECT SUBSTRING(name, 1, 2), COUNT(*) AS "Count"
FROM mytable
GROUP BY SUBSTRING(name, 1, 2)