Professional Documents
Culture Documents
Practice Question CHP 2
Practice Question CHP 2
2. List the employees whose salary is more than 3000 after 20% increment.
Select ename , sal from emp
Where (sal+sal*0.2)>3000;
3. List the employees, deptno who does not belong to dept 20 or 30.
Select ename, deptno from emp
Where deptno NOT IN(20,30);
4. List all employees and their no,jobs who joined before 1981.
Select empno, ename, job from emp
Where hire_date<’01-JAN-1981’;
5. List all the ename, sal whose annual sal does not fall from 22000 to 45000.
Select empno, ename, sal from emp
Where sal NOT BETWEEN 1600 and 50000;
8. Display the name of employee who does not work under any mgr.
Select ename from emp
Where mgr IS NULL;
Client
10. Find all the clients having ‘I’ as second letter in their name.
Select name from client
Where name LIKE ‘_ i%’;
11. Find all the clients who does not stay in Mumbai or Chennai.
Select name, city from client
Where city NOT IN (‘mumbai’,’chennai’);
12. Select all clients having balance below 2000 and above 3000.
Select name , balance from client
Where balance_due NOT BETWEEN 2000 and 3000;
13. List all names having name consist of five alphabets only.
Select name from client
Where name LIKE ‘_ _ _ _ _’;
Q2. Concate and display all the employees name with their jobs with a space in between.
2. Select ename || ‘ ‘ || job from emp where empno=7369;
Q5. Select and display the part of all employees name starting at 1st position and ending at 3rd
position.
5. Select substr(ename,1,3) from emp where empno=7369;
Q6. Replace and display the word TICK with TACK.
6. Select replace(‘tick and tack’ , ‘t’, ‘c’) from dual;
Q7.Find out the length of the name of the department whose number is 20.
7. Select length(dname) from dept where deptno=20;
Q9. Extract the number from the character ,’a’ and display.
9. Select ascii(‘a’) from dual;
Q!0. Display all the employees name by left padding with ‘*’ and Right padding with ‘#’.
10. Select lpad(ename , 10, ‘*’), rpad(ename , 10, ‘#’) from emp;
Q11. Concat all the employees name along with their jobs and with a string in
between”is a”.
11. Select concat (concat (ename, ‘is a’), job) from emp;
Numeric Functions
Write the queries based on emp table , Dept table or dual table.
Q4. Display the salary of the employee no 7369 and round it upto 3 decimal places.
4. Select sal, round(sal, -3) from emp where empno=7369;
Q5. Display the salary of the employee no 7369 and truncate it upto 3 decimal places.
5. Select sal, trunc(sal, -3) from emp where empno=7369;
Q8.Write the function to convert the value 113 to 100 and 110.
8. Select trunc(113,-1) , trunc(113,-2) from dual;
Date functions:
Sample examples:
1. Select round (’02-01-2020’ , day) from dual;
Aggregate functions:
Clauses:
Join:
1. Display the number of employees in each department who are working in different
departments along with their deptno respectively.
Select dept.deptno, count (empno) from emp,dept Where dept.deptno = emp.deptno
Groupby dept.deptno;