메뉴 건너뛰기

조회 수 139 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

 

 
-- ifnull(fee_enter,0)
 
use haksa;
 
select * from fee;
 
 
 
 
 
-- 등록금 총액을 구하라 (입학금 +수업료)
 
select stu_no,(fee_enter+fee_price) from fee;
 
select stu_no,(ifnull(fee_enter,0)+fee_price) from fee;
 
납입금 총액을 구하라 등록금총액 - 장학금 총액
 
select stu_no,fee_price-ifnull(jang_total,0) from fee;
 
 
 
 
 
-- 우편본호가 150-051인 동지역과 지역전화번호를 구하라
 
select * from post;
select concat(post_dong,ddd) from post where post_no = '150-051';
 
 
 
 
 
 
-- 학번이 20001001 인 학생의 학번 이름 영문이름을 출력하라
use haksa;
select * from student;
show TABLES;
 
select stu_no, stu_name, upper(stu_ename) from student where stu_no='20001001';
 
 
 
 
 
 
 
 
-- 학적테이블에서 학번과 이름, 영문이름을 출력하라, 단, 영문이름의 첫 글자는 대문자로 나머지는 소문자로 출력하라
 
select stu_no, concat(upper(substring(stu_ename,1,1)),lower(substring(stu_ename,2,12))) from student;
 
 
 
 
 
 
 
-- 영문이름의 길이가 정확히 11자인 학생의 학번과 영문이름을 출력하라
select stu_no, stu_ename from student where length(stu_ename)='11';
 
 
 
 
 
 
-- except girl
 
select stu_no,stu_name,id_num from student where substring(id_num,8,1)=1;
 
 
select stu_no, jang_total from fee where jang_total is not null;
 
 
 
 
 
 
 
--  등록 테이블에서 장학금을 1000000원 이상 지급 받은 학생중에서 2회 이상 지급 받은 학생의 학번과,
-- 지급받은 횟수를 학번 내림차순으로 출력하라
select stu_no, count(jang_total)
from fee
where jang_total is not null
and jang_total > 1000000
group by stu_no
HAVING count(jang_total)>1;
 
 
 
 
 
 
 
 
-- 수강신청테이블에서 2006년도 1학기에 수강한 학생의 학번과 수강년도, 학기 , 교과목코드 , 교수코드를 교수코드 오름차순으로 나타내어라
select stu_no,att_year,att_term,sub_code, prof_code 
from attend
where att_year='2006'
and att_term='1';
order by prof_code 
 
 
 
 
 
 
 
-- 학생들의 학번, 이름, 수강신청구분을 나타내어라 , 단, 수강신청구분은 ATTEND 테이블에 있다.
select student.stu_no,stu_name,att_div 
from student, attend
where student.stu_no=attend.stu_no
;
 
 
 
 
 
 
 
-- 수강테이블의 학번과 이름, 수강과목코드, 교수코드 , 교수명을 나타내어라 
 
select a.stu_no, s.stu_name, a.sub_code,p.prof_code,p.prof_name
from attend a, professor p, student s
where a.prof_code=p.prof_code
and a.stu_no=s.stu_no
 
 
 
 
-- 학적테이블의 학번과 이름, 보관성적테이블의 성적취득년도, 학기, 신청학점, 취득학점, 평점 평균을 나타내어라 
 
select s.stu_no,s.stu_name, sc.sco_year, sc.sco_term,sc.req_point,sc.take_point,sc.exam_avg
from student s, score sc
where s.stu_no=sc.stu_no;
 
 
 
 
 
 
-- 학적테이블의 학번과 이름, 수강테이블의 수강신청년도, 학기, 수강신청유무를 나타내어라
 
select s.stu_name, s.stu_no, a.att_date, a.att_term, a.att_div
from student s, attend a
where s.stu_no=a.stu_no;
 
 
 
 
-- 학적테이블의 학번과 이름, 수강테이블의 수강신청년도 , 학기, 수강신청유무를 나타내어라 , 단
-- 중복은 배제한다. 
 
select DISTINCT s.stu_name, s.stu_no, a.att_date, a.att_term, a.att_div
from student s, attend a
where s.stu_no=a.stu_no;
 
 
 
 
 
-- 적어도 한번이상 장학금을 받은 학생의 이름을 나타내어라
select * from fee;
 
select DISTINCT s.stu_name,f.jang_code ,f.fee_year,f.fee_term
from student s, fee f
where s.stu_no=f.stu_no
and f.jang_code is not null;
 
 
select DISTINCT s.stu_name
from student s, fee f
where s.stu_no=f.stu_no
and f.jang_code is not null;
 
 
 
select DISTINCT s.stu_name, count(f.jang_code)
from student s, fee f
where s.stu_no=f.stu_no
group by s.stu_name
having  count(jang_code) >=1;
 
 
 
-- 박정인 학생보다 나이가 더 많은 학생의 이름과 생년을 나타내어라
 
select s.stu_name, s.birth_year
from student s, student st
where st.stu_name='박정인'
and s.birth_year < st.birth_year
;
 
 
(select s.stu_name,(year(now()) - s.birth_year +1) age 
from student s
where s.stu_name='박정인');
 
 
 
 
 
-- 각 학생에 대하여 수강신청 과목코드 , 수강학점을 나타내어라 
select * from student;
select * from attend;
select s.stu_name,a.sub_code,a.att_point
from student s, attend a
where s.stu_no=a.stu_no;
 
 
 
 
-- 장학금을 받은 학생의 학번과 이름을 나타내어라
 
select DISTINCT s.stu_no, s.stu_name
from student s, fee f
where s.stu_no=f.stu_no
and f.jang_code is not null;
 
 
 
-- 등록을 한 모든 학생의 학번과 이름을 출력하라 
 
select DISTINCT stu_no from attend where att_div='Y';
 
select DISTINCT s.stu_name,s.stu_no
from student s, attend a
where s.stu_no=a.stu_no
and a.att_div='Y';






 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
 
 
 
-- ifnull(fee_enter,0)
 
use haksa;
 
select * from fee;
 
-- 등록금 총액을 구하라 (입학금 +수업료)
 
select stu_no,(fee_enter+fee_price) from fee;
 
select stu_no,(ifnull(fee_enter,0)+fee_price) from fee;
 
납입금 총액을 구하라 등록금총액 - 장학금 총액
 
select stu_no,fee_price-ifnull(jang_total,0from fee;
 
-- 우편본호가 150-051인 동지역과 지역전화번호를 구하라
select * from post;
select concat(post_dong,ddd) from post where post_no = '150-051';
 
-- 학번이 20001001 인 학생의 학번 이름 영문이름을 출력하라
use haksa;
select * from student;
show TABLES;
 
select stu_no, stu_name, upper(stu_ename) from student where stu_no='20001001';
 
 
 
 
-- 학적테이블에서 학번과 이름, 영문이름을 출력하라, 단, 영문이름의 첫 글자는 대문자로 나머지는 소문자로 출력하라
 
select stu_no, concat(upper(substring(stu_ename,1,1)),lower(substring(stu_ename,2,12))) from student;
 
 
 
-- 영문이름의 길이가 정확히 11자인 학생의 학번과 영문이름을 출력하라
select stu_no, stu_ename from student where length(stu_ename)='11';
 
-- except girl
 
select stu_no,stu_name,id_num from student where substring(id_num,8,1)=1;
 
 
select stu_no, jang_total from fee where jang_total is not null;
 
--  등록 테이블에서 장학금을 1000000원 이상 지급 받은 학생중에서 2회 이상 지급 받은 학생의 학번과,
-- 지급받은 횟수를 학번 내림차순으로 출력하라
select stu_no, count(jang_total)
from fee
where jang_total is not null
and jang_total > 1000000
group by stu_no
HAVING count(jang_total)>1;
 
 
-- 수강신청테이블에서 2006년도 1학기에 수강한 학생의 학번과 수강년도, 학기 , 교과목코드 , 교수코드를 교수코드 오름차순으로 나타내어라
select stu_no,att_year,att_term,sub_code, prof_code 
from attend
where att_year='2006'
and att_term='1';
order by prof_code 
 
 
-- 학생들의 학번, 이름, 수강신청구분을 나타내어라 , 단, 수강신청구분은 ATTEND 테이블에 있다.
select student.stu_no,stu_name,att_div 
from student, attend
where student.stu_no=attend.stu_no
;
 
 
-- 수강테이블의 학번과 이름, 수강과목코드, 교수코드 , 교수명을 나타내어라 
 
select a.stu_no, s.stu_name, a.sub_code,p.prof_code,p.prof_name
from attend a, professor p, student s
where a.prof_code=p.prof_code
and a.stu_no=s.stu_no
 
 
-- 학적테이블의 학번과 이름, 보관성적테이블의 성적취득년도, 학기, 신청학점, 취득학점, 평점 평균을 나타내어라 
 
select s.stu_no,s.stu_name, sc.sco_year, sc.sco_term,sc.req_point,sc.take_point,sc.exam_avg
from student s, score sc
where s.stu_no=sc.stu_no;
 
-- 학적테이블의 학번과 이름, 수강테이블의 수강신청년도, 학기, 수강신청유무를 나타내어라
 
select s.stu_name, s.stu_no, a.att_date, a.att_term, a.att_div
from student s, attend a
where s.stu_no=a.stu_no;
 
-- 학적테이블의 학번과 이름, 수강테이블의 수강신청년도 , 학기, 수강신청유무를 나타내어라 , 단
-- 중복은 배제한다. 
 
select DISTINCT s.stu_name, s.stu_no, a.att_date, a.att_term, a.att_div
from student s, attend a
where s.stu_no=a.stu_no;
 
 
-- 적어도 한번이상 장학금을 받은 학생의 이름을 나타내어라
select * from fee;
 
select DISTINCT s.stu_name,f.jang_code ,f.fee_year,f.fee_term
from student s, fee f
where s.stu_no=f.stu_no
and f.jang_code is not null;
 
 
select DISTINCT s.stu_name
from student s, fee f
where s.stu_no=f.stu_no
and f.jang_code is not null;
 
 
 
select DISTINCT s.stu_name, count(f.jang_code)
from student s, fee f
where s.stu_no=f.stu_no
group by s.stu_name
having  count(jang_code) >=1;
 
-- 박정인 학생보다 나이가 더 많은 학생의 이름과 생년을 나타내어라
 
select s.stu_name, s.birth_year
from student s, student st
where st.stu_name='박정인'
and s.birth_year < st.birth_year
;
 
 
(select s.stu_name,(year(now()) - s.birth_year +1) age 
from student s
where s.stu_name='박정인');
 
 
 
-- 각 학생에 대하여 수강신청 과목코드 , 수강학점을 나타내어라 
select * from student;
select * from attend;
select s.stu_name,a.sub_code,a.att_point
from student s, attend a
where s.stu_no=a.stu_no;
 
 
-- 장학금을 받은 학생의 학번과 이름을 나타내어라
 
select DISTINCT s.stu_no, s.stu_name
from student s, fee f
where s.stu_no=f.stu_no
and f.jang_code is not null;
 
-- 등록을 한 모든 학생의 학번과 이름을 출력하라 
 
select DISTINCT stu_no from attend where att_div='Y';
 
select DISTINCT s.stu_name,s.stu_no
from student s, attend a
where s.stu_no=a.stu_no
and a.att_div='Y';
cs

 


  1. No Image 12Apr
    by
    2017/04/12 Views 5017 

    MySQL 계정생성하기

  2. No Image 27Feb
    by
    2014/02/27 Views 5693 

    Mysql 기본 명령어

  3. MYSQL 기초문법&예제&문제

  4. 27Mar
    by 조쉬
    2021/03/27 Views 139 

    MYSQL 기초문법&예제&문제 2

  5. No Image 23Dec
    by
    2016/12/23 Views 5500 

    mysql 날짜 관련 date_add, date_format

  6. MySQL 대용량 DBMS 개선 사례

  7. No Image 18Jul
    by
    2018/07/18 Views 1973 

    MySQL 마스터/마스터 replication 에서 AUTO_INCREMENT 문제 해결 방법

  8. No Image 27Feb
    by
    2014/02/27 Views 6254 

    MySql 문자열 합치기

  9. MYSQL 부속질의어 예제&문제 9

  10. No Image 30Aug
    by
    2016/08/30 Views 5842 

    MySQL 서버 데몬이 죽었을때 다시 실행하는 방법

  11. No Image 12Apr
    by
    2017/04/12 Views 5330 

    MySQL 손상된 테이블 복구

  12. No Image 25Nov
    by
    2020/11/25 Views 362 

    MySQL 암호화 방법

  13. MySQL 에서 NULL 값 처리

  14. No Image 12Apr
    by
    2017/04/12 Views 5365 

    mySQL 에서 날자표현 방법

  15. No Image 12Apr
    by
    2017/04/12 Views 5727 

    MySQL 에서 랜덤(random)으로 레코드 읽어오기

  16. MySql 에서 외래키(FK) 설정하는 방법과 Toad 에서 확인하기

  17. MySQL 에서 테이블에 이미 존재하는 값으로 UPDATE 하는 경우

  18. No Image 28Dec
    by
    2017/12/28 Views 3917 

    MySQL 연결 속도

  19. MySql 윈도우에서 DB dump 백업과 복구하기

  20. MySql 의 Trigger(트리거) 로 정보 업데이트

Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved