有一个表有“工号,姓名,性别,上级主管工号,部门,出生日期,离职日期,工资”
1、要查找各员式及主管人员资料要怎么写
2、当离职日期=“”时,显示“在职”,小于当前系统日期时,显示“离职”,大于当前系统日期时显示“即将离职”
3、怎么找工资比该单位平均工资低的人员
4、怎么找各部门工资最高的前二个人
1、要查找各员式及主管人员资料要怎么写
2、当离职日期=“”时,显示“在职”,小于当前系统日期时,显示“离职”,大于当前系统日期时显示“即将离职”
3、怎么找工资比该单位平均工资低的人员
4、怎么找各部门工资最高的前二个人
select * from table where 工号 = ?
2、当离职日期=“”时,显示“在职”,小于当前系统日期时,显示“离职”,大于当前系统日期时显示“即将离职”
select case when 离职日期 = '' then '在职' when 离职日期 < getdate() then '离职' when 离职日期 > etdate() then '即将离职' end from table
3、怎么找工资比该单位平均工资低的人员
select *from table where 工资< 平均工资
select *
from tb
where 工资<(select avg(工资) from tb)4
select top 2 *
from tb
order by 工资 desc
select top 2 *
from tb
order by 工资 desc group by 部门
工号 姓名 性别 上级主管工号 部门 出生日期 离职日期 工资
1 A M 0 Z
2 B M 1 Z
3 C M 0 X
4 D W 2 X(注:上级主管工号!=0 表示是上级主管)
1、要查找各员工及主管人员资料要怎么写select * from Table where 上级主管工号=0 (查普通员工的资料)
select * from Table where 上级主管工号!=0 (查普主管人员资料)2、当离职日期=“”时,显示“在职”,小于当前系统日期时,显示“离职”,大于当前系统日期时显示“即将离职”select case when 离职日期 = '' then '在职' when 离职日期 < getdate() then '离职' when 离职日期 > etdate() then '即将离职' end from table 3、怎么找工资比该单位平均工资低的人员select * from Table where 工资<(select AVG(工资) from Table)4、怎么找各部门工资最高的前二个人select Top 2 * from Table Group by 部门 order by 工资 dese