0% found this document useful (0 votes)
19 views6 pages

Lecture 02

oracle database slides notes

Uploaded by

Irfan Ali
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)
19 views6 pages

Lecture 02

oracle database slides notes

Uploaded by

Irfan Ali
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/ 6

Lecture 02

1). Create a query to display the last name and salary of employees earning
more than $12,000.
Place your SQL statement in a text file named lab2_1.sql. Run your query.

SELECT last_name,salary

FROM employees

WHERE salary >12000;

2) Create a query to display the employee last name and department number for
employee number
176.

SELECT last_name , department_id

FROM employees

WHERE employee_id =176;

3) Modify lab2_1.sql to display the last name and salary for all employees whose
salary is not in the range of $5,000 and $12,000. Place your SQL statement in a
text file named lab2_3.sql.
SELECT last_name,salary

FROM employees

WHERE salary NOT IN(5000,12000);

4) Display the employee last name, job ID, and start date of employees hired
between February 20, 1998, and May 1, 1998. Order the query in ascending order
by start date.

SELECT last_name,job_id,hire_date

FROM employees

WHERE hire_date BETWEEN '20-FEB-1998' AND '01-MAY-1998';

5) Display the last name and department number of all employees in departments
20 and 50 in alphabetical order by name.
SELECT last_name,department_id

FROM employees

WHERE department_id IN(20,50)

ORDER BY last_name;

6) Modify lab2_3.sql to list the last name and salary of employees who earn
between $5,000 and $12,000, and are in department 20 or 50. Label the columns
Employee and Monthly Salary, respectively. Resave lab2_3.sql as lab2_6.sql. Run
the statement in lab2_6.sql.

SELECT last_name AS EMPLOYEES , salary AS "MONTHLY SALARY"

FROM employees

WHERE department_id IN (20,50) AND salary BETWEEN 5000 AND 12000 ;

7) Display the last name and hire date of every employee who was hired in 1994.

SELECT last_name,hire_date

FROM employees

WHERE hire_date like '%94';

8) 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 ;

9) Display the last name, salary, and commission for all employees who earn
commissions. Sort data in descending order of salary and commissions.

SELECT last_name,salary,commission_pct

FROM employees

WHERE commission_pct IS NOT NULL

ORDER BY salary,commission_pct desc ;

10) Display the last names of all employees where the third letter of the name is
an a.

SELECT last_name

FROM employees

WHERE last_name like '__a%';


11) Display the last name of all employees who have an a and an e in their last
name.

SELECT last_name

FROM employees

WHERE last_name like '%e%a%';

If you want an extra challenge, complete the following exercises:

12.Display the last name, job, and salary for all employees whose job is sales
representative or stock clerk and whose salary is not equal to $2,500, $3,500, or
$7,000.

SELECT last_name,job_id,salary

FROM employees

WHERE job_id IN('ST_CLERK' , 'SA_REP' ) AND salary NOT IN('2500','3500','7000');

13) Modify lab2_6.sql to display the last name, salary, and commission for all
employees whose commission amount is 20%. Resave lab2_6.sql as lab2_13.sql.
Rerun the statement in lab2_13.sql.
SELECT last_name AS EMPLOYEE , salary AS "MONTHLY
SALARY",COMMISSION_PCT

FROM employees

WHERE department_id IN (20,50) AND salary BETWEEN 5000 AND 12000 AND
commission_pct like '';

You might also like