求sql语句,有难度的。谢谢
table
id wc
1  23
2  28
3  31-1/2
4 31-2/2
5  39-1/3
6 24
7 39-2/3
8 39-3/3
WC中有相同的都会用-分数来区分的。我要得到:
id wc 个数
1   23  1
2    28 2
3    31 2
4    24  1
5   39   3
谢谢
------解决方案--------------------果然有难度,看不懂。
------解决方案--------------------
SQL code
select substring_index(wc,'-',1),count(*)
from table
group by substring_index(wc,'-',1)