oracle 基本操作和小技巧

您所在的位置:网站首页 住址查询电话 oracle 基本操作和小技巧

oracle 基本操作和小技巧

2024-04-27 15:59| 来源: 网络整理| 查看: 265

--模糊查询--1.查询住址为“山东”的学生姓名、电话、住址select studentname,phone,address from student where address like '山东%';

--2.查询名称中含有“数据库”字样科目信息select *from subjectwhere subjectname like '%数据库%';

--3.查询电话中以“1387”开头的学生信息 select * from student where phone like '1387%';

--4.查询姓姜的,单名的学生信息 select * from student where studentname like '姜_';

--5.查询学号为1004的学生参加的科目编号为1、2、3的考试成绩信息select *from resultwhere studentno=1004 and subjectno in(1,2,3);

--6.查询出生日期在1980-1-1到1989-12-31之间学生信息 select * from student where borndate between to_date('1980-1-1','YYYY-MM-DD') and to_date('1989-12-31','YYYY-MM-DD');

--分组统计:--1.查询每个学期/年级学时数超过50的课程数select gradeid 年级,count(*) 课程数from subjectwhere classhour>50group by gradeid;

--2.查询每学期学生的平均年龄select gradeid 年级,avg(months_between(sysdate,borndate)/12) 平均年龄from studentgroup by gradeid;

 

--3.查询北京地区的每学期学生人数select gradeid 年级,count(*) 人数from studentwhere address like '北京%'group by gradeid;

--4.查询参加考试的学生中,平均分及格的学生记录,并按照成绩降序排列select studentno 学号,avg(studentresult) 平均成绩from resultgroup by studentnohaving avg(studentresult)>=60order by 2 desc;

--5.查询考试日期为2010年3月22日的课程的及格平均分select subjectno 课程编号, avg(studentresult) 平均分from resultwhere examdate=to_date('2010-03-22','YYYY-MM-DD') and studentresult>=60group by subjectno;

--6.查询至少2次考试不及格的学生学号、不及格次数select studentno 学号,count(studentno) 不及格的次数from resultwhere studentresult=2;

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3