목록computer science (51)
IT STUDY LOG
# 숫자 함수 (참고) dual - 데이터를 한 행만 가지고 있는 테이블 SELECT * FROM dual; ROUND - 지정된 자리로 반올림 수행 SELECT ROUND(456.7897, 2), 200, 'Hello' FROM emp WHERE ROWNUM = 1; -- MySQL LIMIT 기능, 지정하지 않을 경우 emp 테이블 행 개수만큼 출력됨 SELECT ROUND(456.7897, 1) FROM dual; SELECT ROUND(456.7897, 0) FROM dual; SELECT ROUND(456.7897, -1) -- 1의 자리 FROM dual; SELECT ROUND(456.7897, -2) -- 10의 자리 FROM dual; TRUNC - 지정된 자리에서 버림 수행 SELECT..
# 문자 함수 LOWER, UPPER, INITCAP LOWER : 소문자로 변환 UPPER : 대문자로 변환 INITCAP : 모든 단어의 첫문자를 대문자로 변환 SELECT ename, job, ename||' '||job name , LOWER(ename||' '||job) "lower name" , UPPER(LOWER(ename||' '||job)) "upper name" , INITCAP(ename||' '||job) "initcap name" FROM emp -- DATA값의 경우 대소문자를 구분하므로 조건 절에서 주로 사용 WHERE LOWER(ename) = 'smith' OR UPPER(ename) = 'SMITH'; CONCAT - 두 문자열을 연결 SELECT CONCAT(ename..
# 함수의 구분 1. 내장 함수 단일 행 함수 : 행 당 하나의 결과를 반환 다중 행 함수 : 행 그룹을 조작해 행 그룹당 하나의 결과를 반환 2. 사용자 정의 함수 # 단일 행 함수 데이터 조작을 위해 사용 SELECT, WHERE, ORDER BY 절에 사용 가능 데이터 타입 변경 가능 중첩 사용 가능 반환되는 각 행에 대해 작업 수행 인자를 받아들여 하나의 결과를 반환
# 기본 SELECT문 동작 조회 SELECT empno, ename, sal FROM emp; SELECT * FROM emp; 사칙연산 일부 컬럼만 읽고자할 때도 데이터를 읽을 때는 행 전체를 읽어온 뒤 출력 형태를 변경 SELECT empno, ename, sal, sal + 100, sal - 100, sal * 10, sal / 10 FROM emp; NULL NULL 값을 포함한 연산의 경우 결과값 또한 NULL SELECT empno, ename, sal, comm, sal + comm FROM emp; NULL 값이 아닌 경우에만 산술연산 수행하도록 작성 SELECT empno, ename, sal, comm, NVL(sal, sal + comm) AS TOTAL_SAL FROM emp; ..
# 문제 내용 프로그래머스: 타겟 넘버 # 알고리즘 분류 DFS/BFS # 풀이 class Solution { public int dfs(int prev, int index, int[] numbers, int target) { if (index >= numbers.length) { if (target == prev) { return 1; } return 0; } // 사칙 연산은 +, - 뿐 int current_plus = prev + numbers[index]; int current_minus = prev - numbers[index]; int count = 0; count += dfs(current_plus, index+1, numbers, target); count += dfs(current_mi..