DBMS Lab 2
DBMS Lab 2
1. Write a query to display EMPLOYEE_ID, FIRST_NAME, and SALARY of employees whose SALARY
is less than $3000.
Query 01#
select employee_id, first_name, salary
from employees
where salary < 3000;
2. Write a query to display FIRST_NAME, LASTNAME of all employees whose first name starts with
letter ‘A’.
Query 02#
Select first_name, last_name
from employees
where first_name like “A%”;
3. Write a query to display FIRST_NAME, JOB_ID, DEPARTMENT_ID of employees who are either
PU_CLERK or belongs to MANAGER_ID = 114.
Query 03#
Select first_name, job_id, demartment_id
from employees’
where job_id = “PU_CLERK” or manager_id = 114;
4. Write a query to display EMPLOYEE_ID, FIRST_NAME, and SALARY of employees whose salaries
lies in the range of $1500 to $3000;
Query 04#
Select employee_id, first_name, salary
From employees
6. Write a query to display first names of all employees that end with alphabet ‘N’.
Query 06#
select first_name
from employees
where first_name like "%N"
7. Write a query to display FIRST_NAME, JOB_ID, DEPARTMENT_ID of employees who are not
PU_CLERK.
Query 07#
select first_name, job_id, department_id
from employees
where job_id <> "PU_CLERK";
8. Write a query to display EMPLOYEE_ID, FIRST_NAME, and SALARY of those employees who do
not have salaries of $3300, $3200, $2200.
Query 08#
select employee_id, first_name, salary
from employees
where salary not in (3300, 3200,2200);
9. Write a query to display names of those employees whose first name starts with ‘A’ and ends with
‘N’.
Query 09#
select first_name
from employees
where first_name like "A%N";
10. Write a query to display the list of employee names that have letters ‘LA’ in their names.
Query 10#
select first_name
from employees
where first_name like "LA%";
11. Write a query to display the EMPLOYEE_ID, FIRST_NAME, and SALARY of employees. In that, the
highest paid employee should display first and lowest paid should display last.
Query 11#
select employee_id, first_name, salary
from employees
order by salary desc;
12. Write a query to display FIRST_NAME of employees that have "a" in the second position.
Query 12#
select first_name
from employees
where first_name like "_A%";
13. Write a query to display EMPLOYEE_ID, FIRST_NAME, and SALARY of employees whose salaries
do not lies in the range of $1500 to $3000;
Query 13#
select employee_id, first_name, salary
from employees
where salary not between 1500 and 300;
14. Write a query to display FIRST_NAME, LAST_NAME and DEPARTMENT_ID of all employees in
departments 30 or 100 in ascending order.
Query 14#
Select first_name, last_name, department_id
from employees
where department_id in (30,100)
order by department_id;
15. Write a query to display FIRST_NAME, LAST_NAME and SALARY for all employees whose salary
is not in the range $10,000 through $15,000 and are in department 30 or 100.
Query 15#
Select first_name, last_name, salary
from employees
where department_id in (30,100)
#where department_id =30 or department_id =100
and salary not between 10000 and 15000;
16. Write a query to display FIRST_NAME, LAST_NAME and HIRE_DATE for all employees who were
hired in 1987.
Query 16#
select first_name, last_name, hire_date
from employees
where year (hire_date) = 1987;
17. Write a query to display the LAST_NAME of employees whose LAST_NAME have exactly 6
characters.
Query 17#
select last_name
from employees
where length(last_name) = 6;
18. Write a query to display FIRST_NAME, SALARY and PF (15% of salary) of all employees.
Query 18#
20. Write a query to display FIRST_NAME, SALARY and NET_SALARY after 500 deduction from salary
of all employees;
Query 20#
select first_name, salary, salary-500 as "Net Salary"
from employees;
The End