ORACLE... ์ด๊ฒ ๋ ๋ฒจ2๋ฉด ๋ ๋ฒจ3์....๐ค
๐ DATETIME ํ๋ณํ
์ ๊น๋จน๋ ์ฌ๋๐โ๏ธ
- YYYY : 2021
- YY : 21
- MM : 06 (๋ ์๋ฆฌ ์)
- DD : 09 (๋ ์๋ฆฌ ์ผ)
- HH24 : 13 (12์๊ฐ์ผ๋ก ๋ฐ๊พธ๊ณ ์ถ์ผ๋ฉด HH12)
- MI : 34 (๋ถ)
- SS : 56 (์ด)
TO_CHAR(DATETIME, 'YYYY-MM-DD') /* 2021-06-09 */
TO_CHAR(DATETIME, 'YY-MM-DD') /* 21-06-09 */
TO_CHAR(DATETIME, 'HH24') /* 13 */
TO_CHAR(DATETIME, 'HH12') /* 01 */
TO_DATE(SYSDATE, 'YYYY/MM/DD:HH24:MI:SS') /* 2021/06/09:02:34:56 */
TO_DATE(SYSDATE, 'DAY Mon YY') /* ์์์ผ 6์ 9 */
๐์ค๋ณต ์ ๊ฑฐ (DISTINCT)
- DISTINCT ์ปฌ๋ผ์ด 1๊ฐ์ธ ๊ฒฝ์ฐ
SELECT DISTINCT [์ถ๋ ฅํ ์ปฌ๋ผ]
FROM [ํ
์ด๋ธ๋ช
];
SELECT COUNT( DISTINCT [์ถ๋ ฅํ ์ปฌ๋ผ] )
FROM [ํ
์ด๋ธ๋ช
];
- DISTINCT ์ปฌ๋ผ์ด ์ฌ๋ฌ๊ฐ์ธ ๊ฒฝ์ฐ
SELECT DISTINCT [์ปฌ๋ผ1], [์ปฌ๋ผ2]
FROM [ํ
์ด๋ธ๋ช
]
ORDER BY [์ปฌ๋ผ1];
์ด๋ฐ ์ฟผ๋ฆฌ๊ฐ ์๋ค๊ณ ํ๋ฉด!
์ปฌ๋ผ1 | ์ปฌ๋ผ2 |
A | 100 |
A | 200 |
B | 150 |
C | 250 |
D | 100 |
์ปฌ๋ผ1์ A๊ฐ 2๊ฐ๊ฐ ์๊ณ , ์ปฌ๋ผ2์๋ 100์ด 2๊ฐ ์๋๋ฐ ์ ์ค๋ณต ์ ๊ฑฐ๊ฐ ์๋๊ฑฐ์ง?! ๋ผ๊ณ ์๊ฐํ ์ ๋ ์์ง๋ง!
A-100, A-200, B-150, C-250, D-100 ์ด๋ ๊ฒ ์ง์ง์ด์ง ๊ฒ์ ์ค๋ณต๋ง ์ ๊ฑฐ๋๋ฏ๋ก ์ ๋ ๊ฒ ๋์ค๋๊ฒ ๋ง๋ค๊ณ ํฉ๋๋ค๐ต
SELECT COUNT(*)
FROM (
SELECT DISTINCT [์ปฌ๋ผ1], [์ปฌ๋ผ2]
FROM [ํ
์ด๋ธ๋ช
]
)
;
์ด ๊ฐฏ์๋ฅผ ๊ตฌํ ๋์๋ ์ด๋ ๊ฒ!
'๐๊ณต๋ถ > ORACLE' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ORACLE] GROUP BY, LIKE, LOWER (0) | 2021.05.31 |
---|
๋๊ธ