+ -
当前位置:首页 → 问答吧 → 怎样判断某员工表成绩列既有不及格,又有及格的?

怎样判断某员工表成绩列既有不及格,又有及格的?

时间:2011-11-16

来源:互联网

怎样判断某员工表成绩列既有不及格,又有及格的?排除每科都及格跟没科都不及格的
sql语句怎样查出符合条件的?

作者: anboat   发布时间: 2011-11-16

SQL code
select * from 员工表 a
where exists(select 1 from 员工表 where 员工ID=a.员工ID and 成绩='不及格')
and exists(select 1 from 员工表 where 员工ID=a.员工ID and 成绩='及格')

作者: qianjin036a   发布时间: 2011-11-16

SQL code

select sid
from tb t
where score >= 及格标准线
    and exists (select 1 from tb where sid = t.sid and score < 及格标准线)
group by sid

作者: AcHerat   发布时间: 2011-11-16

select distinct m.name from tb m , tb n 
where m.id = n.id and m.grade >= 60 and m.grade < 60

作者: dawugui   发布时间: 2011-11-16

引用 3 楼 dawugui 的回复:
select distinct m.name from tb m , tb n
where m.id = n.id and m.grade >= 60 and m.grade < 60

select distinct m.name from tb m , tb n  
where m.id = n.id and m.grade >= 60 and n.grade < 60

作者: dawugui   发布时间: 2011-11-16

SQL code
if object_id('t3') is not null
drop table t3
create table t3 
(id int identity(1,1) primary key,name varchar(10),sc1 float ,sc2 float ,sc3 float)
go
insert t3
select 'A',10,20,30 union all
select 'B',20,65,50 union all
select 'C',60,80,90
go
select * from t3 as a where
not exists (select 1 from t3 where a.id=id and sc1<60 and sc2<60 and sc3<60) and
not exists (select 1 from t3 where a.id=id and sc1>=60 and sc2>=60 and sc3>=60)
/*
(所影响的行数为 1 行)
id name sc1  sc2  sc3
-- ---   --   ---   --
2   B  20.0  65.0  50.0

*/
go 
drop table t3

作者: xiaolinyouni   发布时间: 2011-11-16

谢谢了

作者: anboat   发布时间: 2011-11-16

我想写个sql查询语句,表中有用户id字段,状态字段,时间字段。时间一般是一个月的每天,状态分为临时或全职,怎样写一条语句,能够判断这个用户,如果在这个月有两种状态,月如果他的月末状态为全职,就再给个状态字段,值为:临时-全职,否则反之?
例如:case Staff_Status when '全职' then '临时-全职' else '全职-临时' end;
Staff_Status这个中状态时这个月的最后一天的状态

作者: anboat   发布时间: 2011-11-16

楼主的结帖率为0.00%
得到问题的回答后,请及时结帖.

作者: qianjin036a   发布时间: 2011-11-16

引用 8 楼 qianjin036a 的回复:
楼主的结帖率为0.00%
得到问题的回答后,请及时结帖.


尊重别人的劳动

作者: jiemo587   发布时间: 2011-11-16

sorry啊,我是新手,可能是没分了

作者: anboat   发布时间: 2011-11-16

热门下载

更多