当前位置: 代码迷 >> Java Web开发 >> 还是求sql语句啊有关问题,还是没有搞定
  详细解决方案

还是求sql语句啊有关问题,还是没有搞定

热度:5216   发布时间:2013-02-25 21:14:09
还是求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
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!