日期:2014-05-17  浏览次数:21386 次

sum中出现then 1 else 0的的含义
在网上看到一个SQL语句是这样的。

select sum(case when fsalary>9999 and fage<35 then 1 else 0 end) from empinfo;


这里的case/end, then 1 else 0 能起到提高查询效率的作用么?为什么。

请大神们指教。

------解决方案--------------------
不能!
可以这样写啊:
select Count(RowID) From empinfo Where fsalary>9999 and fage<35;