특정 테이블에 주민번호로 부터 나이를 구하기
ec_member 테이블
select * from ec_member;
id passwd name regist_no
usko 1234 고우선 850102-2****** ... 등등
위처럼 데이터가 있다.
/*방법1*/
/*나이가 월수로 계산이 된다.*/
select name, trunc(months_between(sysdate, to_date(case when substr(regist_no,8,1) in ('1','2')
then '19' || substr(regist_no,1,6)
when substr(regist_no,8,1) in ('3','4')
then '20' || substr(regist_no,1,6)
end,'YYYYMMDD'))/12)
,regist_no, current_date
from ec_member;
/*방법2*/
/*나이가 년도별로 계산이 된다.*/
select name, regist_no, "현재" - "생년월일"
from (select name ,substr(case when substr(regist_no,8,1) in ('1','2')
then '19' || substr(regist_no,1,6)
when substr(regist_no,8,1) in ('3','4')
then '20' || substr(regist_no,1,6)
end,1,4) "생년월일",regist_no, to_number(substr('20' || replace(to_char(current_date),'/',''),1,4),'9999') "현재"
from ec_member);
2016년 2월 3일 수요일
피드 구독하기:
댓글 (Atom)
[oracle]백업및 복구
[oracle]백업및 복구 오라클 덤프 백업및 복구 윈도우 서버 기반 간단 정리 --디렉터리 조회 sqlplus 또는 dbtool 입력시작 SELECT * FROM DBA_DIRECTORIES ; --D:...
-
수십대의 서버에 특정 쉘을 실행한다거나 파일을 수정해야할경우 호스트 입력 아이디 입력 패스워드 입력은 여간 짜증나는일이 아닐수 없다. 이를 한방에 해주는 방법 teraterm 를 설치한다( putty 는 버리자 ) 예를 들면 19...
-
pom.xml <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId...
-
notice_state 란 이름의 체크박스가 있다 가정하고 $("input[name=notice_state]").bind("click",false); 끝.
댓글 없음:
댓글 쓰기