sql문제 및 풀이

손원진·2023년 3월 13일
0

[데이터베이스]

목록 보기
4/5

selaries 테이블에 15000만원이 넘는 사람 count


select count(department_name) from salaries where salary > 15000

selaries 테이블에 3번째로 봉급을 많이 받는사람 중복없이 출력하기

select * from 
(select sub.*,
rank() over(order by salary) as rnk 
from(select * from salaries group by salary)sub) 
where rnk=3;

중복을 포함해서 특정 department에 봉급이 가장 낮은 인원들 순 출력하기

select department,keep(dense_rank last order by selary) as selary 
from salaries where department='정보';

union = 다른테이블에 같은 컬럼을 가진 스키마에 데이터를 추가시킴(행)
inner join = 多 대 一, 一 대 多로 연관된 스키마를 기본값으로 연계 on e.OCPID = a.nameId 로 묶어서 열을 출력
e와 a는 별명으로 on조건에 명시해주는 것이다.

write a query that returns all departments and their aggregate salaries

select department, sum(salary)  from salaries GROUP BY  Department 

write the name that returns the name and salary of the professor of the highst with the salary

select professor_name ,max(salary) from SALARIES  

write the name that returns the name and salary of the professor of the highst with the salary in computer science department

select Professor_Name , max(Salary) from SALARIES where
1=1 and
Department  like 'Computer'||'%'
profile
매일 한 걸음

0개의 댓글