반응형
Notice
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 |
Tags
- vsCode
- TensorFlow
- react
- picker
- 네트워크
- localserver
- Chrome
- qunit
- avds
- MachineLearning
- unittest
- ReactNative
- IOS
- webpack
- 리눅스
- build
- linux
- xcode
- node
- 맥
- Android
- MAC
- jest
- VirtualBox
- 센토스
- 개발
- androidstudio
- PYTHON
- centos
Archives
- Today
- Total
로메오의 블로그
[SQL] Oracle SQL Query - CASE WHEN ELSE 본문
반응형
[ORACLE] DOCKER에 ORACLE 11G 설치하기
[POSTGRESQL] DOCKER에 POSTGRESQL 설치하기
SELECT
COMPANY
, PRODUCT
FROM (
SELECT 'Google' COMPANY, 'Android' PRODUCT FROM DUAL
UNION ALL
SELECT 'Google' COMPANY, 'Chrome' PRODUCT FROM DUAL
UNION ALL
SELECT 'Apple' COMPANY, 'Macbook' PRODUCT FROM DUAL
UNION ALL
SELECT 'Apple' COMPANY, 'iPhone' PRODUCT FROM DUAL
UNION ALL
SELECT 'Sony' COMPANY, 'walkman' PRODUCT FROM DUAL
UNION ALL
SELECT 'Samsung' COMPANY, 'Gallexy' PRODUCT FROM DUAL
);
COMPANY PRODUCT
------- -------
Google Android
Google Chrome
Apple Macbook
Apple iPhone
Sony walkman
Samsung Gallexy
6 rows selected.
회사와 상품이 등록된 테이블에
CASE 문으로 국가 컬럼을 추가하겠습니다.
SELECT
COMPANY
, PRODUCT
, CASE
WHEN COMPANY = 'Samsung' THEN 'KOREA'
WHEN COMPANY = 'Sony' THEN 'JAPAN'
ELSE 'USA'
END AS COUNTRY
FROM (
SELECT 'Google' COMPANY, 'Android' PRODUCT FROM DUAL
UNION ALL
SELECT 'Google' COMPANY, 'Chrome' PRODUCT FROM DUAL
UNION ALL
SELECT 'Apple' COMPANY, 'Macbook' PRODUCT FROM DUAL
UNION ALL
SELECT 'Apple' COMPANY, 'iPhone' PRODUCT FROM DUAL
UNION ALL
SELECT 'Sony' COMPANY, 'walkman' PRODUCT FROM DUAL
UNION ALL
SELECT 'Samsung' COMPANY, 'Gallexy' PRODUCT FROM DUAL
);
COMPANY PRODUCT COUNT
------- ------- -----
Google Android USA
Google Chrome USA
Apple Macbook USA
Apple iPhone USA
Sony walkman JAPAN
Samsung Gallexy KOREA
6 rows selected.
회사이름에 따른 조건문으로 COUNTRY 컬럼을 생성했습니다.
반응형
'Backend > Oracle & SQL' 카테고리의 다른 글
[Oracle] 사용자 생성하기 - User / Tablespace / Table 생성하기 (0) | 2019.09.19 |
---|---|
[SQL] Oracle SQL - NVL, NVL2, DECADE (0) | 2019.09.03 |
[SQLDeveloper] locale not recognized 오류 (0) | 2019.09.02 |
[SQL] distinct 중복제거 예제 (1) | 2019.08.29 |
[Postgresql] Docker에 Postgresql 설치하기 (0) | 2019.08.26 |
Comments