if you are using SQL Server, try something likeselect sum (case when score >= 60 and score < 70 then 1 else 0 end) as count from yourtable
解决方案 »
- 请教 SQL Server 统计
- 奇怪的查询结果(第一次遇到这种情况)
- 关于那道趣的算法题:实现24点游戏求解的存储过程
- sqlserver单表检索(千万)每次在半分钟以上,如何解决?
- 求高人帮忙,我的网站被挂马。mssql数据库资料都被删除了,都被加上了<script src=http://8889.ss.la></script>这句话
- update table Set col=B.Num From table A Inner Join #temp B On A.ID=B.ID 运行出错
- 关于数据方面的统计
- 如何Delete掉这些数据?
- 高分请教SQL SERVER 2005中DLL的注册问题
- 如何用VB将SQL SERVER 中的一个表导出到一个新的.DBF文件中
- www.csdn.net 的IP ADDRESS。
- 大家一起讨论学习“用户“与”角色"
select 1 from yourtable into cursor tmpcur where field1>=data1 and field1<data2
ss=_tally
?? ss
对上面我提出的问题我还要进一步说明:当我在用这样一系列语句计算时效率极低:
count to ss(1) for field1>=90 and field1<100
count to ss(2) for field1>=80 and field1<90
count to ...
....
....
....
有没有只用一句高效的语句来代替?
select sum(case when field1>=90 and field1<100 then 1 else 0 end) as ss1,
sum(case when field1>=80 and field1<90 then 1 else 0 end) as ss2,
...
from table