메뉴 건너뛰기

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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

-- select 명령문의 조합 

 

 

-- 학년이 2, 3 학년인 학생의 학번과 이름을 출력하라

select stu_no, stu_name,grade from student where grade in (2 ,3);

 

 

select stu_no, stu_name,grade

from student

where grade = 2

union

select stu_no, stu_name,grade

from student

where grade = 3

 

 

 

-- 적어도 한번 이상 수강신청을 했거나 등록을 한 학생의 학번을 출력하라 

 

select stu_no 

from attend

union

select stu_no

from fee;

 

 

-- 적어도 한번 동아리에 가입했거나,

-- 등록을 하고 그리고 수강신청을 한 학생 중에서

-- 이상의 조건 중 둘 또는 세가지 조건을 만족하는 또는 두개의 조건에 모두 포함되는 각 학생의 학번을 출력하라 

 

 

-- (x)

select stu_no from attend where stu_no in 

(select stu_no from circle

union

select stu_no from fee

);

 

-- (o)

 

select stu_no from circle

union

select stu_no from fee

union 

select stu_no

from attend

where att_div='Y';

 

 

-- 적어도 한번 이상 등록금 납부하고 동아리에 가입한 모든 학생을 출력하라 

-- (단 중복된 행을 제거하지 않고 모두 출력한다. )

 

select stu_no from fee 

UNION all

select stu_no from circle;

 

-- 20061011 학생과 20071307 학생이 받은 장학금액을 출력하라

 

 

select stu_no ,jang_total 

from fee

where stu_no in (20061011, 20071307);

 

 

 

select stu_no, jang_total

from fee

where stu_no =20061011

union

select stu_no, jang_total

from fee

where stu_no =20071307;

 

 

-- -------------------------------------------------------

 

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
-- select 명령문의 조합 
 
 
-- 학년이 2, 3 학년인 학생의 학번과 이름을 출력하라
select stu_no, stu_name,grade from student where grade in (2 ,3);
 
 
select stu_no, stu_name,grade
from student
where grade = 2
union
select stu_no, stu_name,grade
from student
where grade = 3
 
 
 
-- 적어도 한번 이상 수강신청을 했거나 등록을 한 학생의 학번을 출력하라 
 
select stu_no 
from attend
union
select stu_no
from fee;
 
 
-- 적어도 한번 동아리에 가입했거나,
-- 등록을 하고 그리고 수강신청을 한 학생 중에서
-- 이상의 조건 중 둘 또는 세가지 조건을 만족하는 또는 두개의 조건에 모두 포함되는 각 학생의 학번을 출력하라 
 
 
-- (x)
select stu_no from attend where stu_no in 
(select stu_no from circle
union
select stu_no from fee
);
 
-- (o)
 
select stu_no from circle
union
select stu_no from fee
union 
select stu_no
from attend
where att_div='Y';
 
 
-- 적어도 한번 이상 등록금 납부하고 동아리에 가입한 모든 학생을 출력하라 
-- (단 중복된 행을 제거하지 않고 모두 출력한다. )
 
select stu_no from fee 
UNION all
select stu_no from circle;
 
-- 20061011 학생과 20071307 학생이 받은 장학금액을 출력하라
 
 
select stu_no ,jang_total 
from fee
where stu_no in (2006101120071307);
 
 
 
select stu_no, jang_total
from fee
where stu_no =20061011
union
select stu_no, jang_total
from fee
where stu_no =20071307;
 
 
-- -------------------------------------------------------


 


List of Articles
번호 제목 날짜 조회 수
126 한글정렬 order by 2019.02.19 2424
125 하나의 쿼리로 여러 테이블의 데이터 삭제 file 2020.07.28 888
124 필드 변경, 추가, 삭제 2016.12.23 6085
123 특정 테이블만 replication 하거나 제외하는 방법 2018.07.18 2810
122 특정 COLUMN을 제외하고 SELECT/INSERT하는 방법 2017.11.16 8858
121 테이블, 컬럼 charset 변경 2021.03.26 186
120 테이블, 레코드 복사 2021.03.26 162
119 테이블 파티셔닝 2017.12.22 4940
118 테이블 타입(Heap, MyIsam, InnoDB...) 변경하기 2017.04.12 5272
117 테이블 체크, 백업 2016.12.23 7478
116 테이블 복사, 테이블 비우기 2016.12.23 5783
115 컬럼에 포함된 특정문자열을 검색해서 그 문자로 또 다른 테이블검색하기 2016.08.30 6606
114 컬럼내 특정 문자를 다른문자로 변경하고자 할때 2014.02.27 6012
113 중복데이터 하나만 빼고 삭제 2019.01.11 3163
112 전체 텍스트 검색과 파티션 file 2017.12.22 3868
111 전체 텍스트 검색과 파티션 file 2017.12.22 3946
110 일반적인 오류를 해결하는 유용한 정보들 file 2020.11.23 3858
109 이벤트 스케줄러 등록하기 file 2020.06.29 303
108 월의 마지막 일수를 반환하는 함수입니다 2015.12.19 5996
107 외부접근 권한 주기 file 2016.12.23 5949
Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved