Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 화면정의서
- Spring MVC
- 한글깨짐
- Servlet
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194690
- 피그마
- Request
- sendRedirect
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194709&category=questiondetail&tab=community&q=1314387
- https://www.inflearn.com/course/lecture?courseslug=%ea%b9%80%ec%98%81%ed%95%9c%ec%9d%98-%ec%8b%a4%ec%a0%84-%ec%9e%90%eb%b0%94-%ea%b8%b0%eb%b3%b8%ed%8e%b8&unitid=194711
- 매핑 #
- Forwarding
- Break
- GET방식
- 톰캣
- 요구사항정의서
- 김영한
- 다형성 #부모타입 #자식타입
- Dispatcher
- xml
- while문
- WAS
- JSON형식의 response
- webserver #WAS #ServerApp
- CONTINUE
- POST방식
Archives
- Today
- Total
Step it up now
DECODE(A, B, X, Y), 정렬(오름차순 내림차순)/ 강의 시간 예제 본문
강의시간과 학점이 같으면 '일반과목'을 리턴 받은 후 정렬도 하고 싶다면?
강의시간: lec_time
학점: lec_point
DECODE(A, B, X, Y) |
A = B 이면 X를 출력,
A ≠ B 이면 Y를 출력
|
같으면 -> decode (lec_time,lec_point,'일반과목',0)
--같을때만 값을 주었으니 다를때는 무조건 null이다
1단계 - 일반과목 출력
SELECT
decode(lec_time,lec_point,'일반과목',null)
FROM lecture
2단계 - null의 내림차순
SELECT
decode(lec_time,lec_point,'일반과목',null)
FROM lecture
ORDER BY decode(lec_time,lec_point,'일반과목',null) desc;
- null = 모른다 , 결정되지 않았다 . 정렬을 할 수 없다
- 그래서 맨 뒤에 붙였다
- 그래서 null인 컬럼을 내림차순으로 정렬하면 null이 맨 앞에 왔다
3단계 - null의 오름차순
SELECT
decode(lec_time,lec_point,'일반과목',null)
FROM lecture
ORDER BY decode(lec_time,lec_point,'일반과목',null) asc;
'수업 > SQL' 카테고리의 다른 글
procedure 출력 확인 (0) | 2023.11.27 |
---|---|
3명씩 줄 세우기 (0) | 2023.11.26 |
ER-WIN/ DML (0) | 2023.11.26 |
순위 매기기 (rank, rownum) (1) | 2023.11.24 |
let it be 예제 (0) | 2023.11.21 |