0% found this document useful (0 votes)
18 views

Questions Chapter 3

The document contains sample SQL queries and their outputs related to an EMP table with columns like ENAME, JOB, SALARY, HIRE_DATE etc. It also contains practical questions on the EMP table with corresponding SQL queries and outputs. Some examples include queries to display employees hired in 1987, employees whose name contains two As, and employees' 10 day salary who don't have a manager.

Uploaded by

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

Questions Chapter 3

The document contains sample SQL queries and their outputs related to an EMP table with columns like ENAME, JOB, SALARY, HIRE_DATE etc. It also contains practical questions on the EMP table with corresponding SQL queries and outputs. Some examples include queries to display employees hired in 1987, employees whose name contains two As, and employees' 10 day salary who don't have a manager.

Uploaded by

Ali Bugshan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Essentials of Oracle 77

76 Index

E. SELECT ename,sal
FROM emp
ORDER BY sal DESC,ename ASCENDING;

9. Examine the table instance chart for the employee table.

Column
Name ID_NO NAME SALARY DEPT_NO HIRE_DATE
Key type PK FK
NN
Nulls/unique ,UU NN
FK table DEPARTMENT
FK column DEPT_NO
Data Type NUM VARCHAR2 NUM NUM DATE
Length 9 25 8,2 3

You want to display employee hire date from the earliest to latest.
Which SQL
statement would you use?

A. SELECT hire_date. FROM employee;


B. SELECT hire_date. FROM employee ORDER BY hire_date;
C. SELECT hire_date. FROM employee GROUP BY hire_date;
D. SELECT hire_date. FROM employee ORDER BY hire_date
DESC;

10. Which operator would be evaluated first?


A. OR
B. AND
C. NOT
D. IS NULL
Q No 2 : Practical Questions :
1. Show all the records where ename’s third charter is not ‘M’.

ENAME JOB
---------- ---------
ALLEN SALESMAN
WARD SALESMAN
JONES MANAGER
MARTIN SALESMAN
BLAKE MANAGER
…… 13 rows selected
Essentials of Oracle 77

2. Show ename , job and salary of all the employees except WARD,
BLAKE, TURNER, JONES. (Don’t use AND operator)
ENAME JOB SAL
---------- --------- ----------
SMITH CLERK 800
ALLEN SALESMAN 1600
MARTIN SALESMAN 1250
CLARK MANAGER 2450
SCOTT ANALYST 3000
KING PRESIDENT 5000
ADAMS CLERK 1100
JAMES CLERK 950
FORD ANALYST 3000
MILLER CLERK 1300

3. Display the ename, salary, and commission for all employees whose
commission amount is greater than their salary increased by 10%.
ENAME MONTHLY_SAL INCREASED_SAL COMM
---------- ----------- ------------- ----------
MARTIN 1250 1375 1400

4. Display the ename and job title of all employees who do not have a
manager.Chnage the name of Job Column as Work(Work should be
in the same case).

ENAME Work
----- ---------
KING PRESIDENT

5. Find out how many job types we have in emp table.


JOB
---------
CLERK
SALESMAN
PRESIDENT
MANAGER
ANALYST
76 Index

6. Display the following output. Column heading also should be same.


WHO WHAT AND WHEN
---------------------------------------------------
SMITH HELD THE POSITION OF CLERK IN DEPT. NO 20
ALLEN HELD THE POSITION OF SALESMAN IN DEPT. NO 30
WARD HELD THE POSITION OF SALESMAN IN DEPT. NO 30
JONES HELD THE POSITION OF MANAGER IN DEPT. NO 20
...14 rows selected.
7. Display all the employees who were hired in the year 87.

ENAME JOB HIREDATE


---------- --------- ---------
SCOTT ANALYST 19-APR-87
ADAMS CLERK 23-MAY-87

8. Display all those employees from emp table who have two A’s in
their name.

ENAME
----------
ADAMS

9. Display the Net salary of all those employees whose monthly salary
is between 1000 and 3000 and they are working as SALESMAN. Net
salary is calculated based on following formula. (SAL + COMM –
zakat (2.5 % of SAL) + House rent (5% of SAL))

ENAME SAL JOB COMM NET_SAL


---------- ---------- --------- ---------- ----------
ALLEN 1600 SALESMAN 300 1940
WARD 1250 SALESMAN 500 1781.25
MARTIN 1250 SALESMAN 1400 2681.25
TURNER 1500 SALESMAN 0 1537.5

10. Display the 10 days salary for all those persons who don’t have
manager. Consider current salary for 30 days salary.

ENAME TEN_DAYS_SAL
---------- ------------
KING 1666.66667

You might also like