日期:2014-05-18 浏览次数:20543 次
use tempdb; /* create table A ( id int not null, name varchar(10) not null, [工资] int not null, [部门] nvarchar(10) not null ); insert into A(id,name,[工资],[部门]) values (1,'aa',2000,'开发'), (2,'bb',3000,'销售'), (3,'cc',2000,'开发'), (4,'dd',5000,'销售'), (5,'ee',8000,'技术'), (6,'ff',3500,'技术'); */ select [部门], COUNT(case when A.[工资] between 2000 and 4000 then 1 end) as [2000~4000], COUNT(case when A.[工资] between 4001 and 6000 then 1 end) as [4001~6000], COUNT(case when A.[工资] between 6001 and 8000 then 1 end) as [6001~8000] from A group by [部门];
我的异常网推荐解决方案:软件开发者薪资,http://www.aiyiweb.com/other/1391128.html