Oacle 하위 조회 (난이도 있 음)
27312 단어 Oacle
--
--
--
-- ,
-- , in / any/ all
-- Abel
-- 10
SELECT LAST_NAME,SALARY
FROM EMPLOYEES
WHERE SALARY > ( SELECT SALARY
FROM EMPLOYEES
WHERE LAST_NAME = 'Abel')
-- 'Chen' manage
SELECT LAST_NAME,EMPLOYEE_ID
FROM EMPLOYEES
WHERE EMPLOYEE_ID = ( SELECT MANAGER_ID
FROM EMPLOYEES
WHERE LAST_NAME = 'Chen')
-- job_id 141 ,salary 143 ,job_id
SELECT LAST_NAME,JOB_ID,SALARY
FROM EMPLOYEES
WHERE JOB_ID = ( SELECT JOB_ID
FROM EMPLOYEES
WHERE EMPLOYEE_ID = 141)
AND
SALARY > ( SELECT SALARY
FROM EMPLOYEES
WHERE EMPLOYEE_ID = 143 )
-- last_name,job_id salary
SELECT LAST_NAME,JOB_ID,SALARY
FROM EMPLOYEES
WHERE SALARY = (SELECT MIN(SALARY)
FROM EMPLOYEES)
-- 50 id
SELECT DEPARTMENT_ID,MIN(SALARY)
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
HAVING MIN(SALARY) > ( SELECT MIN(SALARY)
FROM EMPLOYEES
WHERE DEPARTMENT_ID = 50 )
-- job_id 'IT_PROG' , ,job_id salary
-- any
-- 9000 9000
SELECT EMPLOYEE_ID,LAST_NAME,JOB_ID,SALARY
FROM EMPLOYEES
WHERE JOB_ID <> 'IT_PROG' AND SALARY < ANY ( SELECT SALARY -- 9000 6000 4800 4200
FROM EMPLOYEES
WHERE JOB_ID = 'IT_PROG' )
-- job_id 'IT_PROG' , ,job_id salary
-- 4200 4200
SELECT EMPLOYEE_ID,LAST_NAME,JOB_ID,SALARY
FROM EMPLOYEES
WHERE JOB_ID <> 'IT_PROG' AND SALARY < ALL ( SELECT SALARY -- 9000 6000 4800 4200
FROM EMPLOYEES
WHERE JOB_ID = 'IT_PROG' )
-- in
------------------------------------------------------------
-- !
-- 41. : last_name, salary
SELECT LAST_NAME,SALARY
FROM EMPLOYEES
WHERE SALARY = (
SELECT MIN(SALARY)
FROM EMPLOYEES
)
--42.
SELECT *
FROM DEPARTMENTS
WHERE DEPARTMENT_ID = (
SELECT DEPARTMENT_ID
FROM EMPLOYEES
HAVING AVG(SALARY) = (
SELECT MIN(AVG(SALARY))
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
)
GROUP BY DEPARTMENT_ID
)
-- 43*.
-- 1
SELECT d.DEPARTMENT_ID "d_id",d.DEPARTMENT_NAME "d_name",Round(AVG(e.SALARY),2) "avg_sala"
FROM DEPARTMENTS d,EMPLOYEES e
WHERE d.DEPARTMENT_ID = (
SELECT DEPARTMENT_ID
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
HAVING AVG(SALARY) = (
SELECT MIN(AVG(SALARY))
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
)
)
AND e.DEPARTMENT_ID = d.DEPARTMENT_ID(+)
GROUP BY d.DEPARTMENT_ID,d.DEPARTMENT_NAME
-- 2
-- ,
SELECT d.*,(SELECT AVG(SALARY) FROM EMPLOYEES WHERE DEPARTMENT_ID = d.DEPARTMENT_ID)
FROM DEPARTMENTS d
WHERE d.DEPARTMENT_ID = (
SELECT DEPARTMENT_ID
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
HAVING AVG(SALARY) = (
SELECT MIN(AVG(SALARY))
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
)
)
44. job
SELECT *
FROM JOBS
WHERE JOB_ID in (
SELECT JOB_ID
FROM EMPLOYEES
HAVING AVG(SALARY) = (
SELECT MAX(AVG(SALARY))
FROM EMPLOYEES
GROUP BY JOB_ID
)
GROUP BY JOB_ID
)
--45. ?
-- 8
SELECT DEPARTMENT_ID,AVG(SALARY)
FROM EMPLOYEES
HAVING AVG(SALARY) > (
SELECT AVG(SALARY)
FROM EMPLOYEES
)
GROUP BY DEPARTMENT_ID
-- 46. manager .
-- 18
SELECT *
FROM EMPLOYEES
WHERE EMPLOYEE_ID in (
SELECT DISTINCT MANAGER_ID
FROM EMPLOYEES
WHERE MANAGER_ID is not null
)
-- 47.
SELECT MIN(SALARY)
FROM EMPLOYEES
WHERE DEPARTMENT_ID = (
SELECT DEPARTMENT_ID
FROM EMPLOYEES
HAVING MAX(SALARY) = (
SELECT MIN(MAX(SALARY))
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
)
GROUP BY DEPARTMENT_ID
)
GROUP BY DEPARTMENT_ID
--48. manager : last_name, department_id, email, salary
SELECT LAST_NAME,DEPARTMENT_ID,EMAIL,SALARY
FROM EMPLOYEES
WHERE EMPLOYEE_ID in (
SELECT DISTINCT MANAGER_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID = (
SELECT DEPARTMENT_ID
FROM EMPLOYEES
HAVING AVG(SALARY) = (
SELECT MAX(AVG(SALARY))
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
)
GROUP BY DEPARTMENT_ID
)
AND MANAGER_ID is not null
)
-- 49. 1999 .
SELECT *
FROM EMPLOYEES
WHERE SALARY = (
SELECT MAX(SALARY)
FROM EMPLOYEES
WHERE TO_CHAR(HIRE_DATE,'yyyy') = '1999'
)
AND TO_CHAR(HIRE_DATE,'yyyy') = '1999'
-- 1. Zlotkey
-- 33
SELECT LAST_NAME,HIRE_DATE
FROM EMPLOYEES
WHERE DEPARTMENT_ID = (
SELECT DEPARTMENT_ID
FROM EMPLOYEES
WHERE LAST_NAME = 'Zlotkey'
)
AND LAST_NAME <> 'Zlotkey'
-- 2. , 。
--51
SELECT EMPLOYEE_ID,LAST_NAME,SALARY
FROM EMPLOYEES
WHERE SALARY > (
SELECT AVG(SALARY)
FROM EMPLOYEES
)
-- 3. ,
--38
SELECT EMPLOYEE_ID,LAST_NAME,SALARY
FROM EMPLOYEES e1
WHERE SALARY > (
SELECT AVG(SALARY)
FROM EMPLOYEES e2
WHERE e1.DEPARTMENT_ID = e2.DEPARTMENT_ID
GROUP BY e2.DEPARTMENT_ID
)
-- 4. u
--72
SELECT EMPLOYEE_ID,LAST_NAME
FROM EMPLOYEES
WHERE DEPARTMENT_ID in(
SELECT DEPARTMENT_ID
FROM EMPLOYEES
WHERE LAST_NAME LIKE '%u%'
)
AND LAST_NAME NOT LIKE '%u%'
-- 5. location_id 1700
-- 18
SELECT EMPLOYEE_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID IN (
SELECT DEPARTMENT_ID
FROM DEPARTMENTS
WHERE LOCATION_ID = '1700'
)
-- 6. King
--14
SELECT LAST_NAME,SALARY
FROM EMPLOYEES
WHERE MANAGER_ID IN (
SELECT EMPLOYEE_ID
FROM EMPLOYEES
WHERE LAST_NAME = 'King'
)
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
activemq 5.5 의 입문 은 설치, 시작, 데이터베이스 지속 화 를 포함한다Apache ActiveMQ 5.5.0 은 주로 유지보수 버 전 으로 130 개가 넘 는 문 제 를 복 구 했 으 며 대부분 bug 와 개선 이 었 다. Improved performance for offline d...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.