Malik Raheel Ahmad (12349) Data Base

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Malik Raheel Ahmad

Sap id 12349
Data base lab test
1) Write a query that displays the last name and salary of employees who earn more than
$12,000 salary.

SELECT last_name, salary FROM employees WHERE salary > 12000;

2) Create a query to display the last name and salary for any employee whose
salary is not in the range of $5,000 to $12,000

Select last_name as "Last Name", salary as "Salary"from employeeswhere salary


NOT between 5000 and 12000;

3 Create a query to display the last name and department number of all
employees in departments 20 or 50 in ascending alphabetical order by name.
select last_name ,department_id from employees where department_id IN
(20,50) order by last_name;

4) Write a query to display the First name, last name, job ID, and start date for
the employees with the last names of Matos and Taylor. Order the query in
ascending order by start date.

select first_name, last_name, employee_id , hire_date from employees where


last_name in('Matos', 'Taylor')order by hire_date asc;

5) Write a query to display the last name and job title of all employees who do
not have a manager.
SELECT last_name, job_id FROM employees WHERE manager_id IS NULL;

6) Write a query to display all employee last names in which the third letter of
the name is a

select last_name from employees where last_name like ('__a%');

7) Write a query to display the last names of all employees who have both an a
and an e in their last name.

select last_name as "Last Name"from employees where last_name like '%a%'


AND last_name like '%e%';
8) Write a Query to display the employee number, last name, salary, and salary
increased by 15.5% (expressed as a whole number) for each employee. Label the
column New Salary

SELECT EMPLOYEE_ID,LAST_NAME,SALARY,SALARY+(SALARY*15.5/100)
NEW_SALARY FROM EMPLOYEES;

9) Write a query to display to display the last name and salary for all employees.
Format the salary to be 15 characters long, left-padded with the $ symbol. Label
the column SALARY

select last_name , lpad(salary, 15, '$')from employees;

10) Create a report to display the current date. Label the column Date.
Select sysdate "Date" from dual;

11) Write a query to display the average and maximum salary of those
employees who have odd employee number

select avg(salary), max(salary)from employees where mod(employee_id,2)=1;

You might also like