Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

SampleOfQuestions_SQL

ICT

Uploaded by

hsna mardhiah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

SampleOfQuestions_SQL

ICT

Uploaded by

hsna mardhiah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ICT200 – LAB EXERCISES ON SQL[DML ONLY]. PLEASE REFER TO empdb or employeedb DATABASE.

a) Display all employees which received the bonus more than rm500.
Answer : select * from employee where bonus > 500

Evidence:

b) Display the department name for ‘michael’.


Answer :
select d.deptno, d.deptname from employee e, department d where e.dept=d.deptno and e.
firstname='MICHAEL'

Evidence:

c) Display all staff which the bonus received is more than the average bonus received by all
staffs. Display the staff no, name, bonus, dept number and department name.
Answer : select e.empno, concat(e.firstname,' ',e.mid,'
',e.lastname) as fullname, e.bonus, d.deptno, d.deptname from employee e, department d
where e.dept = d.deptno and e.bonus > (select avg(bonus) from employee)

Evidence:

1
d) Display all staffs from the employee table which their last name ended with ‘SON’. Display
their empno, dept and fullname.
Answer:

Evidence:

e) Display all staffs from the employee table which attached to department number which start
with ‘A’.
Answer:

Evidence:

f) Update the extension number for Christine to ‘3356’


Answer:

Evidence:

g) Update the department number from the table department for project named ‘OPERATION
SUPPORT’ to new department number ‘X99’.
Answer:

Evidence:

h) Delete the ‘Christine’ record’s from the table employee.


Answer:

Evidence:

i) Display the empno, fullname, gender and how long the service (duration) of each employee.
Answer:

Evidence:

2
j) Determine the new salary for each employee if management decided to increase the salary
up to 15% from the current salary. Display the empno, fullname, current salary, new salary
and total increment. Format the currency until 2 decimal places.
Answer:

Evidence:

k) List all staffs who attached to the department named ‘MANUFACTURING SYSTEMS’.

Display the empno, fullname and sex.

For this type of question, the student is not allowed to use the deptno ‘D11’ for
‘MANUFACTURING SYSTEMS’. You must use the department name as mentioned in the
question.
Answer:

Evidence:

l) Count number of employees attached at each department. Dipslay the deptno and number
of employees.

Answer:

Evidence:

m) List the project number and project name which managed by ‘John’ (first name). You are not
allowed to refer what is the empno of ‘John’. Use the name as given.
Answer:

Evidence:

n) Display the empno, fullname, departname and projectname specifically for ‘Theodore’
Answer:

Evidence:

3
o) Determine list of employees which they are not the manager of the department. Display the
empno and fullname. [use subquery]
Answer:

Evidence:

p) Determine how many projects handled by each employee. Display the empno, fullname and
total project handled.
Answer:

Evidence:

q) Count number of employees which their salary more than average salary of all employees.
Answer:

Evidence:

r) Determine number of projects organized by each department. Display the deptno,


departname and number of projects organized.
Answer:

Evidence:

s) List the depno, empno and fullname and salary which the salary is the highest in the
department.
Answer:

Evidence:

4
t) Display the total salary by the department. Display the deptno, department name and total
salary.
Answer:

Evidence:

u) Display the total duration of each project handled by each department and who handled the
project. Display the empno, fulllname, deptno, departname, projno, projname and duration
of the project.
Answer:

Evidence:

Remember this structure:


SELECT xxx, yyy, zzz
FROM aaa
WHERE xxx NOT IN mmm
GROUP BY xxx, yyy
HAVING AVG(zzz) > 10000
ORDER BY xxx

You might also like