目录
以下语法的实现利用scott 员工管理系统? ?hr 人事管理系统
//切换用户,切换为sys
conn sys/123456@iweb as sysdba;
//设置行显示
set linesize 120;
//解锁/加锁 hr 用户
alter user hr account unlock/lock;
//设定用户密码
alter user hr identified by "123456";
//链接
connect hr/123456@iweb
//查看列
desc regions;
基本语法
select * from tablename; -- * 代表所有列
--查询指定的列的信息
select empno,ename from emp;
条件:比较 : > < = != <> >= <=,? null判断,? between,and? 逻辑and, or,? ? ?in? ? like? ??
--字符串比较
select * from emp where ename ='SCOTT';
--null判断
select * from emp where comm is null;
select * from emp where comm is not null;
--between and
--工资在1250到3000之间的员工
select * from emp where sal between 1250 and 3000;
--部门为10和20的员工
select * from emp where deptno=10 or deptno=20;
--不在部门10,20,30 的员工
select * from emp where deptno not in (10,20,30);
--找出名字包含字母A的员工
--%表示任意字符 _ 表示一个字符
select * from emp where ename like '%A%';
--查询所有工作,去除重复行 distinct
select distinct jod from emp;
--||连接符
select 'Dear' || ename from emp;
--order by 排序,一定在语句末尾,asc正序,desc倒序
select * from emp order by sal desc;
--upper将小写转大写
select upper('abc') from dual;
--lower将大写转小写
select lower(ename) from emp;
--initcap将首字母大写
select initcap('smith') from dual;
--concat 连接 等同于||
select concat(initcap('dear '),initcap(ename)) from emp;
--substr 截取字符串
select substr('abcdefg',3,4) from dual;
--length 计算字符串长度
select length('abc') from dual;
--replace 替换指定字符串
select replace('www.baidu.com','www','aaa') from dual;
--instr 返回指定字符开始的位置
select instr('www.baidu.com','baidu') from dual;
--trim 去除左右两边空格
select tirm(' jack ') from dual;
--round 四舍五入,floor 向下取整,ceil向上取整 , mod 取模
select round(4.5),floor(4.9),ceil(4.3),mod(10.3) from dual;
--trunc 截取数值
select turnc(3.555,2) from dual;
select systimestamp from dual; ---系统当前时间
select sydate from dual;
--统计员工入职多少个月,不足一月按一个月算
select ceil(months_between(sysdate,hiredate)) from emp;
--入职超过三年的员工
select add_months(sysdate,1) from dual;
select * from where hiredate< add_months(sysdate,-36);--add_months(sysdate,-36)减36个月
--date day
select next_day(sysdate,'星期一') from dual;
--last_day 某月的最后一天
select last_day(sysdate) from dual;
--日期可以进行+ -运算,其单位是天
select trunc(last_day(sysdate))- trunc(sysdate,'month')+1 from dual;
--extract摘取
select extract(month from sysdate) from dual;
--to_date 转日期
--找出1981年之前入职的员工
select * from emp where hiredate <to_date('1982-01-01','yyyy-MM-dd');
--to_char转字符串
select * from emp order by to_cahr(sal);
--to_number 转数值
select to_number('0011') from dual;
--nvl 对null 值的处理,给null一个缺省值
--nvl 是一个用于处理 NULL 值的函数。它接受两个参数,如果第一个参数为 NULL,则返回第二个参数;
-- 如果第一个参数不为 NULL,则返回第一个参数的值。
select nvl(comm,0)+100 from emp; --comm为奖金
--nullif 它接受两个参数,如果这两个参数的值相等,则返回 NULL;如果这两个参数的值不相等,
-- 则返回第一个参数的值
select nullif('1','2') from dual;
--nvl2 它接受三个参数,根据第一个参数的值来确定返回值。
select nvl2(111,1,2) from dual;
--coalesce 它接受多个参数,返回第一个不为 NULL 的参数值。
select coalesce(comm,0) from emp;
--decode 10开发,20测试,30运维
-- 是一个用于实现条件判断和值替换的函数。它接受多个参数,并根据特定的逻辑判断返回不同的结果。
select ename,deptno,decode(deptno,10,'开发',20,'测试',30,'运维') from emp;
--case 用于实现复杂的条件判断和值替换
select ename,deptno, case deptno
when 10 then '开发'
when 20 then '测试'
else '运维' end from emp;
--练习
--1. 找出每个月倒数第三天受雇的员工(如:2009-5-29)
select * from emp where hiredate=last_day(hiredate)-2;
--2. 所有员工名字前加上 Dear ,并且名字首字母大写
select concat(initcap('Dear '),initcap(ename)) from emp;
--3. 找出姓名为 5 个字母的员工
SELECT * FROM emp where length(ename)=5;
--3. 找出姓名中不带 R 这个字母的员工
select * from emp where ename not like '%R%';
--4. 显示所有员工,按名字降序排列,若相同,则按工资升序排序
select * from emp order by ename asc,sal desc;
--5. 找到 2 月份受雇的员工
select * from emp where extract(month from hiredate)=2;
--6. 列出员工加入公司的天数(四舍五入)
select round(sysdate-hiredate) from emp;
--group by关键字
--分组函数 count avg sum max min
--统计员工人数 null不参与计算
select count(ename) from emp;
--统计各部门工资大于2000的人
select count(ename),deptno from emp where sal>2000 group by deptno;
--分组后加having条件
select deptno,count(ename) from emp group by deptno having count(ename)>4;
--多条件分组
--查询各部门各职位的平均工资
select deptno,job,avg(sal) from emp group by deptno,job;
--排序应该在分组之后
--练习
--1. 分组统计各部门下工资>500 的员工的平均工资
select avg(sal),deptno from emp where sal>500 group by deptno;
--2. 统计各部门下平均工资大于 500 的部门
select deptno,avg(sal) from emp group by deptno having avg(sal)>500;
--3. 算出部门 30 中得到最多奖金的员工奖金
select max(comm) from emp where deptno=30;
--4. 算出每个职位的员工数和最低工资
select count(ename),min(sal),job from emp group by job;
--5. 算出每个部门,每个职位的平均工资和平均奖金(平均值包括没有奖金),如果平均奖金大于300,显示“奖金不错”,如果平均奖金 100 到 300,显示“奖金一般”,如果平均奖金小于 100,显示“基本没有奖金”,按部门编号降序,平均工资降序排列
select avg(sal),avg(comm) from emp group by deptno,job order by deptno desc,avg(sal) desc;
--6. 列出员工表中每个部门的员工数,和部门 no
select count(ename),deptno from emp group by deptno;
--7. 分组统计每个部门下,每种职位的平均奖金(也要算没奖金的人)和总工资(包括奖金)
select avg(coalesce(comm,0)),deptno,job from emp group by deptno,job;
笛卡尔积,在关系型数据库中,笛卡尔积是指对两个表进行全连接操作,即将一个表的每一行与另一个表的每一行进行组合,生成一个新的结果表。结果表的行数等于两个原始表的行数之积,列数等于两个原始表的列数之和。
假设有两个表A和B,分别有m行和n行,那么它们的笛卡尔积结果表C将有m x n行。C中的每一行由A和B中对应位置的行组合而成。
--等值链接
select * from emp e,dept d where e.deptno=d.deptno;
--非等值连接
--查看所有员工和他的工资等级
select * from emp e,salgrade s where e.sal between s.losal and s.hisal;
--自连接(即自己查询自己)
--查询员工姓名及其领导的姓名(查询不到无领导的人)
select e.ename,m.ename from emp e,emp m where e.mgr=m.empno;
--左外连接 left join on
--查询员工姓名及其领导的姓名,并显示无领导员工
SELECT e.ename, m.ename FROM emp e LEFT JOIN emp m ON e.mgr = m.empno;
--右外连接
--查询员工信息和部门信息,无部门的员工也显示
slect * from emp e right join dept d on e.deptno=d.deptno;
--查询员工信息和部门信息,包含没员工的部门
select d.deptno,count(e.ename) from emp e right join dept d on e.deptno=d.deptno group by d.deptno;
--满外连接
--先插入一个数据
INSERT INTO emp VALUES (8001, 'JACK', 'CLERK', 7782, sysdate, 1300, default, default);
select * from emp e full outer join dept d on e.deptno=d.deptno;--deptno不存在也可以查到
--连接查询(与笛卡尔积的结果一样)
select * from emp e join dept d on e.deptno=d.deptno;
--左连接和右连接区别(左连接保留左表的所有记录,而右连接保留右表的所有记录)
--并集 union(重复的显示一次) union all(重复的也显示)
select * from emp where deptno in(10,20)
union
select * from emp where deptno in(20,30);
--交集 intersect只显示重复的
--差集 minus只显示对方没有的
--子查询(将查询结果作为一张表继续查询)
--单行子查询
--查询工资比7566的工资多的人
select sal from emp empno=7566;
select * from emp where sal>2975;--2975是上一个语句的结果
select * from emp where sal>(select sal from emp empno=7566);
--Null值
--子查询是null 整个结果都为空
--多值 all
select * from emp where sal>all(select sal from emp where deptno=10);
--找出比部门10任意的人工资高 any
select * from emp where sal>any(select sal from emp where deptno=10);
--找出与部门10的人工资相同的人 in
select * from emp where sal in (select sal from emp where deptno=10) and deptno!=10 or deptno is null;
--多行子查询
--TOPM
--找出工资前三的人
--伪列 rowid 数据存储的物理地址(不可变) rownumb 序号(可变)
select t.empno,t.sal,t.rno,t.rid
from (
select e.empno,e.sal,rowid rid,rownum rno
from emp e
order by sal desc
) t
where rownum<=3;
--找排行3-5的
select c.empno,c.sal,rownum
from
(select t.empno,t.sal,t.rno from
(select e.empno,e.sal,rowid rid,rownum rno from emp e order by sal desc) t
where rownum<=5) c
where rownum >=3;
--找出重复数据
select * from emp e where e.empno not in
( select min(m.empno) from emp m group by m.ename,m.job,m.mgr,m.hiredate,m.sal,m.comm,m.deptno);
--若没有empno 用rowid来充当它唯一的列
select * from emp e where rowid not in
( select min(rowid) from emp m group by m.ename,m.job,m.mgr,m.hiredate,m.sal,m.comm,m.deptno);
--列出员工表中每个部门的员工数,和部门 no
select count(ename),deptno from emp group by deptno;
--列出员工表中每个部门的员工数(员工数必须大于 3),和部门名称
select count(ename),dept.dname from emp left join dept on emp.deptno = dept.deptno group by dept.dname having count(ename)>3;
--找出工资比 jones 多的员工
select * from emp where sal>(select sal from emp where ename='JONES');
--列出所有员工的姓名和其上级的姓名
select e.ename,m.ename from emp e,emp m where e.mgr=m.empno;
--以职位分组,找出平均工资最高的两种职位
select t.avgsal,t.job,rownum from
(select avg(sal) avgsal,job from emp group by job order by avgsal desc) t
where rownum <=2;
--查找出不在部门 20,且比部门 20 中任何一个人工资都高的员工姓名、部门名称
select e.ename,d.dname from emp e,dept d
where sal >any(select sal from emp where deptno=20) and d.deptno!=20 and d.deptno=e.deptno;
--得到平均工资大于 2000 的工作职种
select avg(sal),job from emp group by job having avg(sal) >2000;
--分部门得到工资大于 2000 的所有员工的平均工资,并且平均工资还要大于2500
select avg(t.sal) from (select * from emp where sal>2000) t group by t.deptno having avg(sal)>2500;
--得到每个月工资总数最少的那个部门的部门编号,部门名称,部门位置
select t.deptno,d.dname,rownum from
(select sum(sal) csal,deptno from emp group by deptno order by csal asc) t,dept d
where t.deptno = d.deptno and rownum=1;
select * from salgrade;
--分部门得到平均工资等级为 2 级(等级表)的部门编号
select t.deptno,s.grade from
(select avg(sal) asal,deptno from emp group by deptno) t,salgrade s
where t.asal between s.losal and s.hisal and s.grade=2;
--查找出部门 10 和部门 20 中,工资最高第 3 名到工资第 5 名的员工的员工名字,部门名字,部门位置
select c.ename,dept.dname,c.rid,c.rno from
(select t.ename,t.sal,t.deptno,rownum rno,t.rid from
(select e.ename,e.sal,e.deptno,rowid rid from emp e where deptno in(10,20) order by sal desc) t
where rownum <=5) c left join dept on c.deptno=dept.deptno
where c.rno>=3;
--查找出收入(工资加上奖金(奖金可能为null),下级比自己上级还高的员工编号,员工名字,员工收入
select e.*,e.sal+nvl(e.comm,0) emptotal,m.sal+nvl(m.comm,0) mgrtotal from emp e,emp m
where e.mgr=m.empno and mgrtotal<emptotal;
--查找出工资等级不为 4 级的员工的员工名字,部门名字,部门位置
select t.ename,d.dname,d.rowid from
(select e.ename,e.sal,s.grade,e.deptno from emp e,salgrade s where e.sal between s.losal and s.hisal) t,dept d
where t.deptno = d.deptno and t.grade=4;
--查找出职位和'MARTIN' 或者'SMITH'一样的员工的平均工资
select avg(sal),job from emp
where job in(select job from emp where ename in('MARTIN','SMITH')) group by job;
--查找出不属于任何部门的员工
select * from emp where deptno is null;
--按部门统计员工数,查处员工数最多的部门的第二名到第五名(列出部门名字,部门位置)
select dept.dname,dept.rowid,c.rno from
(select t.cename,t.deptno,rownum rno from
(select count(ename) cename,deptno from emp group by deptno order by count(ename) desc) t
where rownum <=5) c left join dept on c.deptno=dept.deptno
where c.rno>=2;
--查询出 king 所在部门的部门号\部门名称\部门人数
select d.dname,d.deptno,t.cc from
(select e.deptno,count(e.ename) cc from emp e group by e.deptno) t,dept d
where t.deptno = d.deptno and d.deptno=(select deptno from emp where emp.ename='KING');
--查询出 king 所在部门的工作年限最大的员工名字
select d.deptno,t.ename,rownum from
(select deptno,ename from emp order by hiredate desc) t,dept d
where t.deptno = d.deptno and d.deptno=(select deptno from emp where emp.ename='KING') and rownum=1;
--查询出工资成本最高的部门的部门号和部门名称
select d.dname,d.deptno,rownum from
(select deptno,sum(sal+nvl(comm,0)) sum_ from emp group by deptno order by sum_ desc) t
,dept d where t.deptno=d.deptno and rownum=1;
--创建表
create table 表名(列名1,列名2,...);--提供主键:唯一标识
eg.
CREATE TABLE student (
sid INT PRIMARY KEY,
sname VARCHAR(100), ---主键,非空,唯一
age INT, ---可变字符串长度
birth DATE, ---日期 年月日格式
sex CHAR(2),
addr VARCHAR(100),
ctime TIMESTAMP ---年月日 时分秒
);
--修改表
--添加列
alter table student add phone varchar(11);
--删除列
alter table student drop column addr;
--修改列
alter table student modify phone varcahr(11);
--修改表名
alter table student rename to stu;
--添加commit即可在其他客户端也看见
--插入数据
insert into stu (sid,sname,age,birth,sex,ctime,phone)
values
(1,'jack',23,to_date('2001-02-23','yyyy-MM-dd','男',systimestamp,'12749384758');
--修改数据
update stu set age =22 where sid=2;
--删除数据
delete from stu where sid=2;
-- 1、查询“c001”课程比“c002”课程成绩高的所有学生的学号;
select sno from sc s group by sno
having
(select score from sc where cno='c001' and sno=s.sno) >
(select score from sc where cno='c002' and sno=s.sno);
-- 2、查询平均成绩大于60 分的同学的学号和平均成绩;
select sno,avg(score) from sc group by sno having avg(score)>60;
-- 3、查询所有同学的学号、姓名、选课数、总成绩;
select s.sno,s.sname,count(sc.cno),sum(score) from student s left join sc on sc.sno=s.sno group by s.sno,s.sname;
-- 4、查询姓“刘”的老师的个数;
select count(tname) from teacher where tname like '刘%';
-- 5、查询没学过“谌燕”老师课的同学的学号、姓名;
select s.sno,s.sname from student s left join sc on sc.sno = s.sno
where sc.cno not in
(select c.cno from course c left join teacher t on t.tno = c.tno where t.tname='谌燕');
-- 6、查询学过“c001”并且也学过编号“c002”课程的同学的学号、姓名;
select sno,sname from student
where sno in (select sno from sc where cno='c001') and sno in(select sno from sc where cno='c002');
-- 7、查询学过“谌燕”老师所教的所有课的同学的学号、姓名;
select distinct s.sno,s.sname from student s left join sc on sc.sno = s.sno
where sc.cno in
(select c.cno from course c left join teacher t on t.tno = c.tno where t.tname='谌燕');
-- 8、查询课程编号“c002”的成绩比课程编号“c001”课程低的所有同学的学号、姓名;
select sno,sname from student s
where
(select score from sc where cno='c001' and sno=s.sno) >
(select score from sc where cno='c002' and sno=s.sno);
-- 9、查询所有课程成绩小于60 分的同学的学号、姓名;
select sno,sname from student s where sno in
(select sno from sc group by sno having max(score)<60);
-- 10、查询没有学全所有课的同学的学号、姓名;
select sno,sname from student where sno not in
(select sno from sc group by sno
having count(cno)=(select count(cno)from course)
) and sno in (select sno from sc);
-- 11、查询至少有一门课与学号为“s001”的同学所学相同的同学的学号和姓名;
select sno,sname from student
where sno in
(select sno from sc where cno in (select cno from sc where sno='s001')) and sno!='s001';
-- 12、把“SC”表中“谌燕”老师教的课的成绩都更改为此课程的平均成绩;
--利用相关子查询 用父表数据 逐条 遍历子表数据
UPDATE sc
SET score = (
SELECT AVG(sc.score)
FROM course c
INNER JOIN teacher tea ON c.tno = tea.tno
WHERE tea.tname = '谌燕' AND sc.cno = c.cno
GROUP BY sc.cno
)
WHERE cno IN (
SELECT cno
FROM course c
INNER JOIN teacher t ON t.tno = c.tno
WHERE t.tname = '谌燕'
GROUP BY cno
);
-- 13、查询和“s001”号的同学学习的课程完全相同的其他同学学号和姓名;
(select t.sno
from
(select * from sc
where cno in (select cno from sc where sno='s001') and sno!='s001') t
inner join student s on s.sno=t.sno
group by t.sno,s.sname
having count(t.cno)=(select count(cno) from sc group by sno having sno='s001'))
minus
(select sno from sc where cno not in (select sc.cno from sc where sc.sno='s001'));
-- 14、删除学习“谌燕”老师课的SC 表记录;
delete from sc where cno in(
select c.cno from course c inner join teacher t on t.tno=c.tno where t.tname='谌燕'
);
-- 15、向SC 表中插入一些记录,这些记录要求符合以下条件:没有上过编号“c002”课程的同学学号、“c002”号课的平均成绩;
insert into sc
select sno,'c002',(select avg(score) from sc where cno='c002') from student where sno not in
(select sno from sc where cno='c002');
-- 16、查询各科成绩最高和最低的分:以如下形式显示:课程ID,最高分,最低分
select cno "课程ID",max(score) "最高分",min(score) "最低分" from sc group by cno;
-- 17、按各科平均成绩从低到高和及格率的百分数从高到低顺序
select cno,avg(score),(select count(score) from sc where score>60 and cno=s.cno)/count(score)*100 || '%' "及格率"
from sc s group by cno order by avg(score),"及格率" desc;
-- 18、查询不同老师所教不同课程平均分从高到低显示
select t.tno,t.cno,avg(t.score) from (
select sc.*,c.tno from sc inner join course c on c.cno=sc.cno
) t group by t.tno,t.cno order by avg(t.score) desc;
-- 19、统计列印各科成绩,各分数段人数:课程ID,课程名称,[100-85],[85-70],[70-60],[ <60]
select s.cno "课程ID",c.cname "课程名称", count(score),
(select count(score) from sc where s.cno=cno and score>=85 and score<=100) "[100-85]",
(select count(score) from sc where s.cno=cno and score>=70 and score<=85) "[85-70]",
(select count(score) from sc where s.cno=cno and score>=60 and score<=70) "[70-60]",
(select count(score) from sc where s.cno=cno and score<60) "[<60]"
from sc s inner join course c on c.cno=s.cno group by s.cno,c.cname;
-- 20、查询各科成绩前三名的记录:(不考虑成绩并列情况)
--查询 各科成绩比自己高的人数 <=2
--相同课的条件下 父表.score>子表.score 大于的个数<=2
select * from sc p where
(select count(sno) from sc c where p.cno=c.cno and p.score<c.score) <=2 order by cno,score;
--方法2
select * from
(select sc.*,row_number() over (partition by cno
order by score desc) rn from sc) t where t.rn <=3;
-- 21、查询每门课程被选修的学生数
select c.cno,count(sc.sno) from course c left join sc on sc.cno=c.cno group by c.cno;
-- 22、查询出只选修了一门课程的全部学生的学号和姓名
select s.sno,s.sname,count(sc.cno) from student s left join sc on sc.sno=s.sno
group by s.sno,s.sname having count(sc.cno)=1;
-- 23、查询男生、女生人数
select ssex,count(sno) from student group by ssex;
-- 24、查询姓“张”的学生名单
select * from student where sname like '张%';
-- 25、查询同名同性学生名单,并统计同名人数
select sname,ssex,count(sname) from student group by sname,ssex;
-- 26、1981 年出生的学生名单(注:Student 表中Sage 列的类型是number)
select * from student where sage=extract(year from sysdate)-1981;
-- 27、查询每门课程的平均成绩,结果按平均成绩升序排列,平均成绩相同时,按课程号降序排列
select cno,avg(score) from sc group by cno order by avg(score),cno desc;
-- 28、查询平均成绩大于85 的所有学生的学号、姓名和平均成绩
select sc.sno,s.sname,avg(score) from student s
join sc on sc.sno=s.sno group by sc.sno,s.sname having avg(score)>80;
-- 29、查询课程名称为“数据库”,且分数低于60 的学生姓名和分数
select s.sname,sc.score from student s join sc on s.sno=sc.sno
and sc.cno=(select cno from course where cname='Oracle') and sc.score<60;
-- 30、查询所有学生的选课情况;
select s.sname,sc.sno,sc.cno from student s,sc where sc.sno=s.sno;
-- 31、查询任何一门课程成绩在70 分以上的姓名、课程名称和分数;
select s.sname,c.cname,sc.score from student s
join sc on s.sno=sc.sno
join course c on c.cno=sc.cno
where sc.score>70;
-- 32、查询不及格的课程,并按课程号从大到小排列
select sc.cno,c.cname from sc join course c on c.cno=sc.cno where score <60 order by cno;
-- 33、查询课程编号为c001 且课程成绩在80 分以上的学生的学号和姓名;
select s.sno,s.sname from student s left join sc on s.sno=sc.sno
where sc.cno='c001' and sc.score>80;
-- 34、求选了课程的学生人数
select count(distinct sno) from sc;
select distinct s.sno,s.sname from student s left join sc on sc.sno=s.sno where sc.score is not null;
-- 35、查询选修“谌燕”老师所授课程的学生中,成绩最高的学生姓名及其成绩
select t.sname,t.score from
(select * from student s
join sc on s.sno=sc.sno
join course c on sc.cno=c.cno
join teacher t on t.tno=c.tno and t.tname='谌燕') t order by t.score desc;
-- 36、查询各个课程及相应的选修人数
select c.cno,count(sc.sno) from course c left join sc on sc.cno=c.cno group by c.cno;
-- 37、查询不同课程成绩相同的学生的学号、课程号、学生成绩
select * from sc s1,sc s2 where s1.sno=s2.sno and s1.score=s2.score and s1.cno!=s2.cno;
-- 38、查询每门功课成绩最好的前两名
select * from sc p where
(select count(sno) from sc c where p.cno=c.cno and p.score<c.score) <=1 order by cno,score;
-- 39、统计每门课程的学生选修人数(超过10 人的课程才统计)。要求输出课程号和选修人数,查询结果按人数降序排列,若人数相同,按课程号升序排列
select cno,count(sno) from sc group by cno having count(sno)>10 order by count(sno) desc,cno;
-- 40、检索至少选修两门课程的学生学号
select sno,count(cno) from sc group by sno having count(cno)>2=;
-- 41、查询全部学生都选修的课程的课程号和课程名
select sc.cno,c.cname,count(sc.sno) from sc
left join course c on c.cno=sc.cno group by sc.cno,c.cname
having count(sc.sno)=(select count(sno) from student);
-- 42、查询两门以上不及格课程的同学的学号及其平均成绩
select sno,count(cno) from sc where score<60 group by sno having count(cno)>2;
-- 43、检索“c004”课程分数小于60,按分数降序排列的同学学号
select sno from sc where score<60 and cno='c004' order by score desc;
-- 44、删除“s002”同学的“c001”课程的成绩
delete from sc where sno='s002' and cno='c001';