还是求sql语句啊,问题,还是没有搞定
如图,有三个表,a1,a2,c1
我希望通过sql语句,可以得到如表D1那样的结果,
后面的字段count是表示出现了几次的计数
[解决办法]
- Java code
select Name,sum(case when id<5 then 1 else 0 end) as count1,sum(case when id>=5 and id<6 then 1 else 0 end) as count2,sum(case when id>6 then 1 else 0 end) as count3from tbgroup by name