[Coding Test_MySQL] 3. MySQL Test 21~30

김미숙's avatar
Mar 07, 2025
[Coding Test_MySQL] 3. MySQL Test 21~30
  1. 21번 이름이 S로 시작하고 마지막 글자가 T인 사람의 모든 정보를 출력하라(단, 이름은 전체 5자리이다.)
select * from emp where ename like 'S%' and ename like '%T';
notion image
 
  1. 22번 첫 번쨰 문자는 관계없고, 두 번쨰 문자가 A인 사람의 정보를 출력하라.
select * from emp where ename like '_A%';
notion image
 
  1. 커미션이 NULL인 사람의 정보를 출력하라.
select * from emp where comm is null;
notion image
 
  1. 커미션이 NULL이 아닌 사람의 정보를 출력하라.
select * from emp where comm is not null;
notion image
 
  1. 부서가 30번 부서이고 급여가 $1,500 이상인 사람의 이름, 부서, 월급을 출력하라.
select ename, deptno, sal from emp where deptno = 30 and sal >= 1500;
notion image
 
  1. 이름의 첫 글자가 K로 시작하거나 부서번호가 30인 사람의 사원번호, 이름, 부서번호를 출력하라.
select empno, ename, deptno from emp where ename like 'K%' or deptno = 30;
notion image
 
  1. 급여가 $1500 이상이고 부서번호가 30번인 사원 중 직업이 MANAGER인 사람의 정보를 추력하라.
select * from emp where deptno = 30 and sal >= 1500 and job = 'manager';
notion image
 
  1. 부서번호가 30인 사람 중 사원번호가 SORT.
select * from emp where deptno = 30 order by empno desc;
notion image
 
  1. 29번 급여가 많은 순으로 SORT하라.
select * from emp order by deptno asc, sal desc;
notion image
 
  1. 부서번호로 ASCENDING SORT 한 후 급여가 많은 사람 순으로 출력하라.
select empno, ename from emp where empno <= 7698;
notion image
Share article

parangdajavous