sql 구문 연습 및 답

2157 단어 sql문장 연습
1 학생표 학생 S\#학 번,sname 이름,difdate 날짜,학급 grade 2 과정 표 course c\#과정 번호,이름 cname 3 성적표 score s\#학 번 c\#과정 번호 성적 score--1 학급 당 몇 명 이 select grade,count(sname)from zestudent group by grade; --2.2007 학년 의 각 학생 의 평균 성적 이 성적 이 없 는 것 은 0 이다.select a.sname,(select avg(nvl(b.score,0)) from ze_score b where b.s#=a.s#) from ze_student a where grade=2007; --3 과목 당 평균 성적 과 최고 성적 최저 성적 2007 급 보류 2 위 소수점 반올림 select b.c\#,avg(b.score),max(b.score),min(nvl(b.score,0)from zestudent a,ze_score b where b.s# = a.s# and a.grade =2007 group by b.c#; --4.2007 급 수학 에 5 점 추가 update zescore set score=nvl(score,0)+5 where s# in (select s# from ze_student where grade=2007) and c# =(select c# from ze_course 코스 where cname='수학');5 90 점 이상 은 우수 90~85 가 양호 하고 60 점 불합격 각 사람의 평균 성적 selects\#,c,case when c>=90 then'우수'when c<90 and c>=60 then'합격'else'불합격'end as jige from(selects\#,avg(score,0)as c from zescore group by s# ) order by jige desc; --6.같은 달 출생 자 수 select tochar(difdate,'mm')as month,count(s\#)as 출생 자 수 from zestudent group by to_char(difdate,'mm'); --7 각 과목 의 합 격 률 과 평균 성적 절취 보류 2 위--합 격 률 select c\#,avg(nvl(score,0)as 평균 성적,sum(nvl(score,0)as 총 성적,count(s\#)as 각 과목 인원,trunc(sum(case when nvl(score,0)>60 then'1'else'0'end)/count(s\#),2)as 합 격 률 from zescore group by c#; --1 인당 합 격 률 selects\#,avg(nvl(score,0)as 평균 성적,sum(nvl(score,0)as 총 성적,count(c\#)as 총 과목,sum(case when nvl(score,0)>60 then 1 else 0 end)/count(c\#)as 합 격 률 from zescore group by s#; --8 이름 삭제 장삼 의 대학 국어 성적 select*from zescore where s# in (select s# from ze_학생 where sname in'장삼')and c\#=(select c\#from zecourse 코스 where cname='대학 국어');9 수학 을 고등 수학 update ze 로 교체course set cname='고등 수학'where cname like'%수학%';--10.포맷 하면 학 번 을 S 로 시작 하 는 12 자리 보충 0 이 안 되 는 것 을 보 여 줍 니 다.-검색 select concat('S',lpad(s\#,11,0)as s\#from zescore ; select concat('S',lpad(s#,11,0)) as s# from ze_student ; --포맷 update zescore set s#= concat('S',lpad(s#,9,0)); update ze_student set s#= concat('S',lpad(s#,9,0)); 네 축구 팀 select a.name,b.name from qiu a,qiu b where a.name

좋은 웹페이지 즐겨찾기