0% found this document useful (0 votes)
2 views13 pages

Document

The document contains a series of SQL queries and their results based on an employee table. It covers various employee attributes such as job titles, salaries, departments, and hire dates, providing specific matches for each query. The queries include filtering conditions for different job roles, salary ranges, and department numbers.

Uploaded by

Monica N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

Document

The document contains a series of SQL queries and their results based on an employee table. It covers various employee attributes such as job titles, salaries, departments, and hire dates, providing specific matches for each query. The queries include filtering conditions for different job roles, salary ranges, and department numbers.

Uploaded by

Monica N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

1.

Employees working as CLERK and earning less than 1500

SELECT *

FROM emp

WHERE job = 'CLERK'

AND sal < 1500;

✅ Matches in your table:

ADAMS (SAL: 1100)

JAMES (SAL: 950)

---

2. Name and Hiredate of Managers in Dept 30

SELECT ename, hiredate

FROM emp

WHERE job = 'MANAGER'

AND deptno = 30;

✅ Matches in your table:

BLAKE (HIREDATE: 01-MAY-81)


---

3. Employees in Dept 30 as SALESMAN with Annual Salary > 14000

(Annual salary = SAL × 12)

SELECT *, sal * 12 AS annual_salary

FROM emp

WHERE job = 'SALESMAN'

AND deptno = 30

AND sal * 12 > 14000;

✅ Matches in your table:

MARTIN (SAL: 1250, Annual: 15000)

TURNER (SAL: 1500, Annual: 18000)

---

4. Employees working in Dept 30 OR as ANALYST

SELECT *

FROM emp

WHERE deptno = 30

OR job = 'ANALYST';
✅ Matches in your table:

WARD (Dept 30)

MARTIN (Dept 30)

BLAKE (Dept 30)

TURNER (Dept 30)

JAMES (Dept 30)

FORD (ANALYST)

---

5. Names of Employees whose salary < 1100 and job = 'CLERK'

SELECT ename

FROM emp

WHERE job = 'CLERK'

AND sal < 1100;

Here are the SQL queries and answers based on the table shown in your
image:
---

6. Names, SAL, Annual SAL, and DEPTNO for employees in DEPT 20 with
SAL > 1100 and annual SAL > 12000

SELECT ename, sal, sal * 12 AS annual_sal, deptno

FROM emp

WHERE deptno = 20

AND sal > 1100

AND sal * 12 > 12000;

✅ Matches in your table:

SMITH (3400, Annual: 40800, Dept 20)

JONES (3400, Annual: 40800, Dept 20)

FORD (3400, Annual: 40800, Dept 20)

---

7. EMPNO and ENAME of MANAGERs in DEPT 20

SELECT empno, ename

FROM emp

WHERE job = 'MANAGER'


AND deptno = 20;

✅ Matches in your table:

JONES (EMPNO: 7566)

---

8. All details of employees in DEPT 20 or DEPT 30

SELECT *

FROM emp

WHERE deptno IN (20, 30);

✅ Matches in your table:

SMITH (Dept 20)

WARD (Dept 30)

JONES (Dept 20)

MARTIN (Dept 30)

BLAKE (Dept 30)

TURNER (Dept 30)


ADAMS (Dept 20)

JAMES (Dept 30)

FORD (Dept 20)

---

9. Employees working as ANALYST in DEPT 10

SELECT *

FROM emp

WHERE job = 'ANALYST'

AND deptno = 10;

✅ Matches in your table:

❌ None found – FORD is an ANALYST, but in Dept 20.

---

10. Employee working as PRESIDENT with SAL = 4000

SELECT *

FROM emp

WHERE job = 'PRESIDENT'


AND sal = 4000;

✅ Matches in your table:

❌ None found – MILLER is a PRESIDENT but earns 10500.

---

11. Names, DEPTNO, and JOB of CLERKs in DEPT 10 or 20

SELECT ename, deptno, job

FROM emp

WHERE job = 'CLERK'

AND deptno IN (10, 20);

✅ Matches in your table:

SMITH (Dept 20, CLERK)

---

12. Details of employees who are CLERK or MANAGER in DEPT 10

SELECT *

FROM emp

WHERE deptno = 10

AND job IN ('CLERK', 'MANAGER');


✅ Matches in your table:

CLARK (MANAGER, Dept 10)

No CLERK in Dept 10.

---

13. Names of employees in DEPT 10, 20, 30, or 40

SELECT ename

FROM emp

WHERE deptno IN (10, 20, 30, 40);

Here are the answers with the SQL queries for Questions 14–20 based on
your uploaded employee table:

14. Details of employees with EMPNO 7902 or 7839

SELECT *

FROM emp

WHERE empno IN (7902, 7839);

✅ Matches in your table:


FORD (7902)

MILLER (7839)

15. Details of employees working as MANAGER, SALESMAN, or CLERK

SELECT *

FROM emp

WHERE job IN (‘MANAGER’, ‘SALESMAN’, ‘CLERK’);

✅ Matches in your table:

SMITH (CLERK)

WARD (SALESMAN)

JONES (MANAGER)

MARTIN (SALESMAN)

BLAKE (MANAGER)

CLARK (MANAGER)

TURNER (SALESMAN)
JAMES (CLERK)

16. Names of employees hired after 1981 and before 1987

SELECT ename

FROM emp

WHERE hiredate > TO_DATE(‘1981-12-31’, ‘YYYY-MM-DD’)

AND hiredate < TO_DATE(‘1987-01-01’, ‘YYYY-MM-DD’);

✅ Matches in your table:

WARD (1982-02-22)

MARTIN (1983-12-02)

CLARK (1984-07-17)

TURNER (1985-08-17)

ADAMS (1986-07-08)

JAMES (1986-07-24)
17. Details of employees earning more than 1250 but less than 3000

SELECT *

FROM emp

WHERE sal > 1250

AND sal < 3000;

✅ Matches in your table:

WARD (SAL: 1800)

MARTIN (SAL: 1255)

TURNER (SAL: 1800)

JAMES (SAL: 1400)

(Note: MARTIN just meets >1250 condition)

18. Names of employees hired after 1981 into DEPT 10 or 30

SELECT ename

FROM emp

WHERE hiredate > TO_DATE(‘1981-12-31’, ‘YYYY-MM-DD’)

AND deptno IN (10, 30);


✅ Matches in your table:

WARD (Dept 30, 1982-02-22)

MARTIN (Dept 30, 1983-12-02)

CLARK (Dept 10, 1984-07-17)

TURNER (Dept 30, 1985-08-17)

JAMES (Dept 30, 1986-07-24)

GOODLU (Dept 10, 1989-03-08)

19. Names and Annual Salary for employees who are MANAGER or CLERK
in DEPT 10 or 30

SELECT ename, sal * 12 AS annual_salary

FROM emp

WHERE job IN (‘MANAGER’, ‘CLERK’)

AND deptno IN (10, 30);

✅ Matches in your table:

CLARK (MANAGER, Dept 10, Annual SAL: 26400)


JAMES (CLERK, Dept 30, Annual SAL: 16800)

20. All details and annual salary where SAL is between 1000 and 4000 and
Annual SAL > 15000

SELECT *, sal * 12 AS annual_salary

FROM emp

WHERE sal BETWEEN 1000 AND 4000

AND sal * 12 > 15000;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy