본문 바로가기
파이썬 게시판

SQL EMP 예제로 배우는 데이터 처리 방법 21-24 (SQL, Pandas, R Prog, Dplyr, SQLDF, PANDASQL, DATA.TABLE)

by 기서무나구물 2020. 11. 21.

포스팅 목차

    SQL EMP 예제로 배우는 데이터 처리 방법 21-24 (SQL, Pandas, R Prog, Dplyr, SQLDF, PANDASQL, DATA.TABLE) 

    SQL 오라클 emp 예제를 대상으로 파이썬 Pandas, R 프로그래밍, R Dplyr, R Sqldf, Python Pandasql, R Data.table 에 대한 사용 방법을 정리해보고 있습니다. 

    아래 예제는 패턴검색(match, substr, grep, grepl, like, stringr::str_detect 함수), subset 함수, , 문자길이(length, len,stringr::str_length, nchar 함수),  not in / in 연산자(isin, np.isin,%in%,  Hmisc패키지의 %nin%), not 연산자('~' ,'!') , where 구문(query, filter,subset), setdiff 차집합, anti_join, 셀프 조인(self_join) 등에 대하여 기술하고 있습니다. 

    - 패턴검색(문자의 시작('^'), 문자의 끝('$'), 하나의 문자('.'), 

    21. Display the names of employees whose names have second alphabet L in their names.
       * 이름의 두 번째 문자가 알파벳 ‘L’인 모든 사원의 이름을 출력하시오
       : 패턴검색(match, substr, grep, grepl, like), subset 함수, stringr 패키지의 str_detect 함수
       : select ename from emp where ename like ‘_L%’;
       
    22. Display the names of employees whose name is exactly five characters in length.
       * 사원의 이름이 5글자인 사원에 대한 정보를 출력하시오
       : 패턴검색(match, substr, grep, grepl, like), subset 함수, stringr 패키지의 str_detect 함수

       : select ename from emp where ename like '_____';

    23. Display the names of employees who are not working as managers.
       * – 관리자 역할(mgr 변수 기준)을 수행하지 않는 직원의 이름을 출력하시오
       : select * from emp minus (select * from emp where empno in (select mgr from emp));
         (or)
         select * from emp where empno not in (select mgr from emp where mgr is not null);
         (or)
         select * from emp e where empno not in (select mgr from emp where e.empno=mgr)

    24. Display the names of employees who are not working as SALESMAN or CLERK or ANALYST.
       * 판매직, 사무직 또는 분석직 이 외의 직원 이름을 출력하시오.
       : select ename from emp where job not in ('CLERK','SALESMAN','ANALYST')


    * 출처 : statwith.com/sql-emp-예제로-배우는-데이터-처리-방법-21-24-sql-pandas-r-prog-dplyr-sqldf-pandasql-data-table

     자기주도온라인무료학습센터 : withmooc.com/courses/

     

    반응형

    댓글