0% found this document useful (0 votes)
67 views4 pages

Assignment 01: F C Riphah International University

This document contains an assignment submission for a database systems course. It includes 11 multiple choice questions about writing SQL queries to retrieve information from database tables. The questions ask the student to write queries to select, filter, and format data based on conditions on column values and to perform aggregate functions. The student provides the SQL code to answer each question.

Uploaded by

DeadPool Pool
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)
67 views4 pages

Assignment 01: F C Riphah International University

This document contains an assignment submission for a database systems course. It includes 11 multiple choice questions about writing SQL queries to retrieve information from database tables. The questions ask the student to write queries to select, filter, and format data based on conditions on column values and to perform aggregate functions. The student provides the SQL code to answer each question.

Uploaded by

DeadPool Pool
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/ 4

FACULTY OF COMPUTING

RIPHAH INTERNATIONAL UNIVERSITY

Assignment 01

Submitted by SAP_ID.

Irfan Ali 2392

DATABASE SYSTEMS

Q.No.1 Write a query that displays the last name and salary of employees who earn more than
$12,000 salary.

Ans:

select last_name, salary

Page 1 of 4
from employees

where salary > 12000;

Q.No.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.

Ans

select last_name, salary

from employees

where salary>12000 or salary<5000;

Q.No3 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.

Ans:

select last_name, department_id

from employees

where department_id in (20,50)

order by last_name;

Q.NO4 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.

Ans

select last_name, job_id, hire_date

from employees

where last_name='Matos' or last_name='Taylor'

order by hire_date;

Q.NO5 Write a query to display the last name and job title of all employees who do not have a
manager.

Ans

select last_name, job_id

Page 2 of 4
from employees

where manager_id is null;

Q.No6 Write a query to display all employee last names in which the third letter of the name is a

Ans

select last_name

 from employees

 where last_name like '__a%';

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

Ans

select last_name

 from employees

 where last_name like '%a%' and last_name like '%e%';

Q.No8 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

Ans

select employee_id, last_name, salary, salary+(salary*15.5/100) "New Salary"

from employees;

Q.No9 Write a query 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.

Ans

select last_name, lpad(salary,15,'$') Salary

 from employees;

Page 3 of 4
Q.No10 Create a report to display the current date. Label the column Date.

Ans

select sysdate from dual;

Q.No11 Write a query to display the average and maximum salary of those employees who have odd
employee number

Ans

Select employee_id,salary

From employees where mod(salary, 2) = 1;

Page 4 of 4

You might also like