All Oracle SQL Questions and Answers
All Oracle SQL Questions and Answers
7. Display the names of all employees who are working in department number 10
8. Display the names of all employees working as clerks and drawing a salary more than
3000
9. Display employee number and names for employees who earn commission
SQL> select e.empno, e.ename from emp e where e.comm is not null;
SQL> select e.empno, e.ename from emp e where e.comm is null or e.comm=0;
11. Display the names of employees who are working as clerk , salesman or analyst and
drawing a salary more than 3000
SQL> select e.ename from emp e where e.job in (‘CLERK’ ,’ANALYST’,’SALESMAN’) and
e.sal>3000;
//Prefer the second one as it is easier to insert new values if required
12. Display the names of employees who are working in the company for the past 5 years
13. Display the list of employees who have joined the company before 30 th june 90 or after
31 st dec 90
SQL> select * from emp e where e.hiredate between ’30-jun-1990′ and ’31-dec-1990′;
15. Display the list of users in your database (using log table)
or
16. Display the names of all tables from the current user
or
// show user works in command line/sql*plus. Might not work in few GUIs
19. Display the names of employees whose name starts with alphabet S
SQL> select e.ename from emp e where e.ename like ‘S%’ or e.ename like ‘s%’;
20. Display employee name from employees whose name ends with alphabet S
SQL> select e.ename from emp e where e.ename like ‘%S’ or e.ename like ‘%s’;
21. Display the names of employees whose names have second alphabet A in their names
SQL> select e.ename from emp e where e.ename like ‘_a%’ or e.ename like ‘_A%’;
22.Display the names of employees whose name is exactly five characters in length
24.Display the names of employees who are not working as SALESMAN or CLERK or
ANALYST
SQL> select e.ename from emp e where e.job not in (‘CLERK’ ,’ANALYST’,’SALESMAN’)
25.Display all rows from emp table. The system should wait after every screen full of
information
SQL> set pause on;
//The first statement is going to turn the pause feature on. Once a page size is reached in
sql*plus [ this can be run in sql*plus or command line alone I think], it will pause and wait
for user input.
//The next statement is going to print a message saying “press return” whenever it is
paused to continue
//The emp records are printed.
36.Display the names of employees in order of salary i.e. the name of the employee earning
highest should appear first
37.Display the names of employees in ascending order of salary lowest salary shoud appear
first
SQL>select e.ename from emp e order by e.sal;
39.Display empnno,ename,deptno and sal. Sort the output first based on name and within
name by deptno and witdhin deptno by sal;
// To see if this is actually working, you need to insert more values which meet such
condition. Try to insert few values with the same name but different depto’s & sal
combinations
40) Display the name of employees along with their annual salary(sal*12). the name of the
employee earning highest annual salary should appear first?
41) Display name,salary,Hra,pf,da,TotalSalary for each employee. The out put should be in
the order of total salary ,hra 15% of salary ,DA 10% of salary .pf 5% salary Total Salary will be
(salary+hra+da)-pf?
42) Display Department numbers and total number of employees working in each
Department?
43) Display the various jobs and total number of employees working in each job group?
47)Display each job along with min of salary being paid in each job group?
48) Display the department Number with more than three employees in each department?
49) Display various jobs along with total salary for each of the job where total salary is
greater than 40000?
SQL>select e.job, sum(e.sal) as totalsal from emp e group by e.job having sum(e.sal)>4000;
50) Display the various jobs along with total number of employees in each job. The output
should contain only those jobs with more than three employees?
SQL> select e.job, count(empno) as employees from emp e group by e.job having
count(empno) >3;
SQL>SELECT E.ENAME FROM EMP E WHERE E.SAL=(SELECT MAX(E.SAL) FROM EMP E);
52) Display the employee Number and name for employee working as clerk and earning
highest salary among the clerks?
53) Display the names of salesman who earns a salary more than the Highest Salary of the
clerk?
54) Display the names of clerks who earn a salary more than the lowest Salary of any
salesman?
55) Display the names of employees who earn a salary more than that of jones or greater
than that of scott?
SQL> SELECT E.ENAME FROM EMP E WHERE E.SAL>(SELECT E.SAL FROM EMP E WHERE
E.ENAME=’JONES’) AND E.SAL>(SELECT E.SAL FROM EMP E WHERE E.ENAME=’SCOTT’)
OR
SELECT E.ENAME FROM EMP E WHERE E.SAL>(SELECT MAX(E.SAL) FROM EMP E WHERE
E.ENAME IN (‘JONES’,’SCOTT’));
//This is done here as the salary needs to be greater than both Scott & Jones. If it is greater
than max, then it is obviously greater individually. If the condition is changed like less than
one and greater than the other etc, then individual queries need to be written
56) Display the names of employees who earn Highest salary in their respective
departments?
SQL>SELECT E.ENAME, E.DEPTNO FROM EMP E WHERE SAL IN (SELECT MAX(SAL) FROM EMP E
GROUP BY DEPTNO)
57) Display the names of employees who earn Highest salaries in their respective job
Groups?
SQL>SELECT E.ENAME, E.JOB FROM EMP E WHERE SAL IN (SELECT MAX(SAL) FROM EMP E
GROUP BY JOB)
60) Display the job groups having Total Salary greater than the maximum salary for
Managers?
SQL> SELECT E.JOB FROM EMP E GROUP BY E.JOB HAVING SUM(E.SAL)>(SELECT MAX(E.SAL)
FROM EMP E WHERE E.JOB=’MANAGER’);
61) Display the names of employees from department number 10 with salary greater than
that of ANY employee working in other departments?
SQL>SELECT E.ENAME FROM EMP E WHERE E.DEPTNO=10 AND E.SAL > ANY (SELECT E2.SAL
FROM EMP E2 WHERE E2.DEPTNO!=E.DEPTNO);
62) Display the names of employees from department number 10 with salary greater than
of ALL employee working in other departments ?
SQL> SELECT E.ENAME FROM EMP E WHERE E.DEPTNO=10 AND E.SAL > ALL (SELECT E2.SAL
FROM EMP E2 WHERE E2.DEPTNO!=E.DEPTNO);
69) Use appropriate function and extract 3 characters starting from 2 characters from the
following string ‘Oracle’ i.e., the output should be ac?
70) Find the first occurrence of character ‘a’ from the following string Computer
Maintenance Corporation?
71) Replace every occurrence of alphabet A with B in the string Aliens (Use Translate
function)?
72) Display the information from the employee table wherever job Manager is found it
should be displayed as Boss?
73) Display empno, ename, deptno from emp table. Instead of display department numbers
display the related department name (Use decode function)?
OR
SELECT
E.EMPNO,E.ENAME,DECODE(E.DEPTNO,10,’ACCOUNTING’,20,’RESEARCH’,30,’SALES’,40,’OPE
RATIONS’) FROM EMP E;
78)Display all the records of emp in the following format “Scott has joined the company on
13th August ninteen ninety?”
SQL> select ename||’ has joined the company on ‘||to_char(hiredate,’day ddth month year’)
as doj from emp;
81) Display the date three months before the Current date?
82) Display the common jobs from department number 10 and 20?
SQL> SELECT JOB FROM EMP WHERE DEPTNO=10 AND JOB IN (SELECT JOB FROM EMP WHERE
DEPTNO=20);
OR
SELECT JOB FROM EMP WHERE DEPTNO=10 INTERSECT SELECT JOB FROM EMP WHERE
DEPTNO=20;
83) Display the jobs found in department 10 and 20. Eliminate duplicate jobs [Eliminate the
jobs that are common in 10&20]?
SQL> (SELECT JOB FROM EMP WHERE DEPTNO=10 UNION SELECT JOB FROM EMP WHERE
DEPTNO=20) MINUS (SELECT JOB FROM EMP WHERE DEPTNO=10 INTERSECT SELECT JOB
FROM EMP WHERE DEPTNO=20);
// This is similar to the sets concept (A-B)U(B-A) OR (AUB)-(A∩B). Suggest a better way to
do this as this is not at all suitable as the deptnos increase. If we add another deptno say
30, then it will be one big mess of a query.
//We can do these effectively by using PL/SQL by storing the repetitive parts as sub queries.
Then it will be similar to an expression.
SQL> SELECT JOB FROM EMP WHERE DEPTNO=10 MINUS SELECT JOB FROM EMP WHERE
DEPTNO!=10;
OR
SELECT JOB FROM EMP WHERE DEPTNO = 10 AND JOB NOT IN (SELECT JOB FROM EMP WHERE
DEPTNO<>10);
85) Display the details of those employees who do not have any person working under him?
SQL> SELECT * FROM EMP WHERE EMPNO NOT IN (SELECT MGR FROM EMP WHERE MGR IS
NOT NULL);
86) Display the details of those employees who are in sales department and grade is 3?
SQL> SELECT E.* FROM EMP E WHERE E.SAL BETWEEN (SELECT LOSAL FROM SALGRADE
WHERE GRADE =3) AND (SELECT HISAL FROM SALGRADE WHERE GRADE =3) AND DEPTNO =
(SELECT DEPTNO FROM DEPT WHERE DNAME=’SALES’);
OR
SELECT E.* FROM EMP E, SALGRADE S, DEPT D WHERE S.GRADE=3 AND E.SAL>S.LOSAL AND
E.SAL<S.HISAL AND E.DEPTNO=D.DEPTNO AND D.DNAME=’SALES’;
SELECT * FROM EMP WHERE EMPNO NOT IN (SELECT MGR FROM EMP WHERE MGR IS NOT
NULL);
//Ensures that the names of employees who are reporting to others are displayed.
88) Display those employees whose name contains not less than 4 characters?
89) Display those departments whose name starts with “S” while location name ends with
“K”?
SQL> SELECT * FROM DEPT D WHERE D.DNAME LIKE ‘S%’ AND D.LOC LIKE ‘%O’;
SQL> SELECT E.* FROM EMP E, EMP E1 WHERE E.MGR = E1.EMPNO AND E1.ENAME=’JONES’;
Or
SELECT * FROM EMP E WHERE E.MGR = (SELECT E1.EMPNO FROM EMP E1 WHERE
E1.ENAME=’JONES’);
// Both produce the same results but the second query will be more cost effective as the
filter will be executed first thus reducing no. of records that need to be processed. In the
first case, a hash join will be done first and then the filters will be checked upon that join
result.
91) Display those employees whose salary is more than 3000 after giving 20% increment?
SQL> SELECT E.ENAME, D.DNAME FROM EMP E, DEPT D WHERE E.DEPTNO = D.DEPTNO;
SQL> SELECT ENAME FROM EMP WHERE DEPTNO = (SELECT DEPTNO FROM DEPT WHERE
DNAME=’SALES’);
94) Display employee name, dept name, salary and commission for those with sal in
between 2000 to 5000 while location is Chicago?
SQL> SELECT E.ENAME, D.DNAME, E.SAL, E.COMM FROM EMP E, DEPT D WHERE
E.DEPTNO=D.DEPTNO AND D.LOC=’CHICAGO’ AND E.SAL BETWEEN 2000 AND 5000;
95) Display those employees whose salary is greater than his manager’s salary?
SQL> SELECT E.* FROM EMP E, EMP E1 WHERE E.MGR = E1.EMPNO AND E.SAL>=E1.SAL;
OR
SELECT * FROM EMP E WHERE E.SAL >= (SELECT E1.SAL FROM EMP E1 WHERE
E1.EMPNO=E.MGR);
// Both produce the same results but the second query will be more cost effective as the
filter will be executed first thus reducing no. of records that need to be processed.
96) Display those employees who are working in the same dept where his manager is work?
SQL> SELECT E.* FROM EMP E, EMP E1 WHERE E.MGR = E1.EMPNO AND
E.DEPTNO=E1.DEPTNO;
OR
SELECT * FROM EMP E WHERE E.DEPTNO = (SELECT E1.DEPTNO FROM EMP E1 WHERE
E1.EMPNO=E.MGR);
//Both produce the same results but the second query will be more cost effective.
97) Display those employees who are not working under any Manager?
SQL> SELECT DISTINCT(E.EMPNO), E.ENAME,E.JOB FROM EMP E,EMP E1 WHERE E.MGR IS NULL
OR (E1.EMPNO=E.MGR AND E1.JOB!=’MANAGER’);
//This ensures that those without a manager, those working under someone other than a
manager are displayed.
SQL>SELECT * FROM EMP WHERE MGR IS NULL;
//This only checks if an employee doesn’t report to anyone i.e. has no mgr entry.
98) Display the grade and employees name for the deptno 10 or 30 but grade is not 4 while
joined the company before 31-DEC-82?
SQL> SELECT S.GRADE, E.ENAME FROM EMP E, SALGRADE S WHERE E.DEPTNO IN(’10’,’30’)
AND E.SAL >= S.LOSAL AND E.SAL<=S.HISAL MINUS (SELECT S.GRADE, E.ENAME FROM EMP
E, SALGRADE S WHERE E.DEPTNO IN(’10’,’30’) AND E.SAL >= S.LOSAL AND E.SAL<=S.HISAL
AND E.HIREDATE<’31-DEC-82′ AND S.GRADE=4);
//But this eliminates all the people who joined after that date. Thus if the restriction was ‘if
the joining date is before that, then the grade should not be 4’, then the first query is apt as
it eliminates those people alone.
99) Update the salary of each employee by 10% increment who are not eligible for
commission?
//I created a copy of emp for this query so as to not affect the original table. We can also
ensure that the original table isn’t affected by using rollback if one hasn’t committed after
executing this query on original emp.
100) Delete those employees who joined the company before 31-Dec-82 while their
department Location is New York or Chicago?
SQL> DELETE FROM EMP2 E WHERE E.HIREDATE < TO_DATE(’31-DEC-82′) AND E.DEPTNO IN
(SELECT D.DEPTNO FROM DEPT2 D WHERE D.LOC IN (‘CHICAGO’,’NEW YORK’));
101) Display employee name, job, deptname, loc for all who are working as manager?
SQL> SELECT E.ENAME, E.JOB, D.DNAME, D.LOC FROM EMP E, DEPT D WHERE
D.DEPTNO=E.DEPTNO AND E.EMPNO IN (SELECT MGR FROM EMP WHERE MGR IS NOT NULL);
OR
102) Display those employees whose manager name is jones and also display their manager
name?
SQL> SELECT E.EMPNO, E.ENAME, M.ENAME AS MANAGER FROM EMP E, EMP M WHERE
E.MGR=M.EMPNO AND M.ENAME=’JONES’;
103)Display name and salary of employees whose salary is equal to hisal of the grade of
Ford?
SQL> SELECT E1.ENAME FROM EMP E1 WHERE E1.SAL = (SELECT S.HISAL FROM SALGRADE S,
EMP E WHERE E.ENAME=’FORD’ AND E.SAL>=S.LOSAL AND E.SAL<=S.HISAL)
104)Display employee name, job, dept name, his manager name and his grade. Display
department wise?
105) List out all the employee names, job, salary, grade and dept name for everyone in a
company except ‘CLERK’ . Sort on salary display the highest salary?
SQL> SELECT E.ENAME, E.JOB, D.DNAME , S.GRADE FROM EMP E, SALGRADE S, DEPT D
WHERE E.JOB!=’CLERK’ AND E.DEPTNO=D.DEPTNO AND E.SAL BETWEEN S.LOSAL AND
S.HISAL ORDER BY E.SAL DESC;
106) Display employee name, job and his manager .Display also employees who are without
managers?
SQL> SELECT E.ENAME, E.JOB, E1.ENAME AS “MGR NAME” FROM EMP E, EMP E1 WHERE
E.MGR=E1.EMPNO UNION SELECT E.ENAME,E.JOB,’NO Manager’ AS “MGR NAME” FROM EMP E
WHERE E.MGR is null;
OR
107) Display top 5 earning employees of a Company?
SQL> SELECT * FROM (SELECT ENAME, EMPNO, SAL, RANK() OVER (ORDER BY SAL DESC) AS
RANK FROM EMP) WHERE RANK<=5;
OR
SELECT * FROM EMP E WHERE 5>(SELECT COUNT(*) FROM EMP E1 WHERE E1.SAL>E.SAL)
ORDER BY E.SAL DESC;
108) Display the names of those employees who are getting the highest salary?
OR
SELECT ENAME, SAL FROM EMP WHERE SAL=(SELECT MAX(SAL) FROM EMP);
// The first case can be used to find the nth highest salary. If you want the first highest
salary, replace N with 1 and so on
109) Display those employees whose salary is equal to average of maximum and minimum
salaries?
111) Display dname where atleast three are working and display only deptname?
SQL> SELECT D.DNAME FROM DEPT D WHERE D.DEPTNO IN (SELECT E.DEPTNO FROM EMP E
GROUP BY E.DEPTNO HAVING COUNT(E.DEPTNO)>3);
OR
//The first query is cost effective. When column values depending on one table alone are the
required output [Here dname is from dept alone], it is always preferable to eliminate the no.
of joins made. Thus use co-related sub queries instead of hash join which is done in the
second query
112) Display names of those managers whose salary is more than average salary of
Company?
OR
SELECT E.ENAME, E.SAL FROM EMP E WHERE E.EMPNO IN(SELECT E.MGR FROM EMP E) AND
E.SAL > (SELECT AVG(E.SAL) FROM EMP E);
113) Display those managers name whose salary is more than average salary of his
employees?
SQL> SELECT E.ENAME FROM EMP E WHERE E.SAL >(SELECT AVG(E1.SAL) FROM EMP E1
WHERE E1.MGR=E.EMPNO);
OR
//The first query is the most cost effective followed by the third but it only considers those
whose job is managers in the third case.
114) Display employee name, sal, comm and netpay for those employees whose netpay is
greater than or equal to any other employee salary of the company?
OR
115) Display those employees whose salary is less than his manager but more than salary of
other managers?
SQL> select * from emp e where e.sal <( select e1.sal from emp e1 where
e.mgr=e1.empno) and e.sal > any (select e1.sal from emp e1 where e1.empno in( select
e.mgr from emp e));
// I am considering the “mgr” column as the basis for deciding managers rather than the job
‘MANAGER’
116) Display all employees names with total sal of company with each employee name?
SQL> SELECT E1.ENAME,(SELECT SUM(SAL) FROM EMP) AS TOTAL_SAL_CMP FROM EMP E1;
OR
SELECT * FROM EMP E WHERE 5>(SELECT COUNT(*) FROM EMP E1 WHERE E1.SAL<E.SAL)
ORDER BY E.SAL ASC;
118) Find out the number of employees whose salary is greater than their managers salary?
SQL> SELECT COUNT(*) FROM EMP E,EMP E1 WHERE E.MGR = E1.EMPNO AND E.SAL>E1.SAL;
119) Display the manager who are not working under president but they are working under
any other manager?
SQL> SELECT E.EMPNO, E.ENAME, M.ENAME AS MANAGER FROM EMP E, EMP M WHERE
E.MGR=M.EMPNO AND M.ENAME!=(SELECT ENAME FROM EMP WHERE JOB=’PRESIDENT’);
SQL> DELETE FROM DEPT1 D WHERE D.DEPTNO NOT IN (SELECT E.DEPTNO FROM EMP E);
121) Delete those records from emp table whose deptno not available in dept table?
SQL> DELETE FROM EMP1 E WHERE E.DEPTNO NOT IN (SELECT D.DEPTNO FROM DEPT D);
122) Display those enames whose salary is out of grade available in salgrade table?
1 1000 2000
2 3000 4000
Now say a emp has a salary of 2500, the above query will result that a valid grade exists.
Thus it is wrong.
(SELECT * FROM EMP) MINUS (SELECT E.* FROM EMP E, SALGRADE S WHERE E.SAL BETWEEN
S.LOSAL AND S.HISAL);
// This ensures results but won’t be suitable for great no. of data items.
123) Display employee name, sal, comm and whose netpay is greater than any other
employee in the company?
// We are assuming here that the netpay should be better than any one employee atleast
124) Display name of those employees who are going to retire by 31-Dec-99 if maximum
job period is 30 years?
OR
127) Display those employees who joined in the company in the month of Dec?
OR
130) Display those employees whose salary is less than (first 2 characters from hiredate
combined with last 2 characters of sal)?
131) Display those employees whose 10% of salary is equal to the year joining?
OR
SQL> SELECT E.ENAME FROM EMP E WHERE E.DEPTNO IN (SELECT D.DEPTNO FROM DEPT D
WHERE D.DNAME IN (‘SALES’,’RESEARCH’));
SQL> SELECT S.GRADE,E.ENAME FROM EMP E,SALGRADE S WHERE E.ENAME = ‘JONES’ AND
E.SAL BETWEEN S.LOSAL AND S.HISAL;
OR
SELECT S.GRADE FROM SALGRADE S WHERE S.LOSAL <= (SELECT E.SAL FROM EMP E WHERE
E.ENAME=’JONES’) AND S.HISAL >= (SELECT E.SAL FROM EMP E WHERE E.ENAME=’JONES’);
134) Display those employees who joined the company before 15th of the month?
OR
SELECT * FROM EMP WHERE EXTRACT(DAY FROM HIREDATE)=15 AND EXTRACT(DAY FROM
HIREDATE)<=20;
135) Display those employees who has joined between 15th 20th of the month?
OR
SELECT * FROM EMP WHERE EXTRACT(DAY FROM HIREDATE)>=15 AND EXTRACT(DAY FROM
HIREDATE)<=20;
136) Delete those records where no of employees in particular department is less than 3?
SQL>DELETE FROM EMP1 WHERE DEPTNO IN (SELECT DEPTNO FROM EMP GROUP BY DEPTNO
HAVING COUNT(DEPTNO)<3);
137) Delete those employee who joined the company 10 years back from today?
OR
OR
SELECT E.ENAME FROM EMP E WHERE E.EMPNO IN (SELECT E.MGR FROM EMP E);
140) Display the dept name the number of characters of which is equal to no of employee in
any other department?
OR
//The first one ensures that same dept isn’t checked. The second one checks for the length
match alone.
141) Display the name of the dept of those employees who joined the company on the same
date?
SQL> SELECT DNAME FROM DEPT WHERE DEPTNO IN (SELECT E.DEPTNO FROM EMP E, EMP
E1 WHERE E.EMPNO!=E1.EMPNO AND E.HIREDATE=E1.HIREDATE AND E.DEPTNO =
E1.DEPTNO );
//This ensures that we are comparing those who are from the same dept.
OR
SELECT DNAME FROM DEPT WHERE DEPTNO IN (SELECT E.DEPTNO FROM EMP E, EMP E1
WHERE E.EMPNO!=E1.EMPNO AND E.HIREDATE=E1.HIREDATE);
//This just compares the hiredates and returns the dept names of the employees [But the
employees with the same date might be from different depts..]
142) Display those employees whose grade is equal to any number of sal but not equal to
first number of sal?
SQL> SELECT E.ENAME, E.SAL , S.GRADE FROM EMP E, SALGRADE S WHERE E.SAL BETWEEN
S.LOSAL AND S.HISAL AND SUBSTR(E.SAL,1,1)!=GRADE AND INSTR(E.SAL,S.GRADE,1,1)!=0;
OR
//The count of those who have employees reporting to them are displayed.
// Set operations and also a set function that are available. Set operations like UNION,
INTERSECT, MINUS etc. can be used. SET function is more complex though.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions144.htm#i1269374
http://docs.oracle.com/cd/B19306_01/server.102/b14200/operators006.htm#i1035617
Refer those two documents for the set function. No point in doing using that for this simple
task. The following query can be used if we want to involve set operations
SELECT COUNT(EMPNO) FROM EMP WHERE EMPNO NOT IN (SELECT A.EMPNO FROM EMP A
MINUS SELECT B.MGR FROM EMP B)
or
SELECT COUNT(EMPNO) FROM EMP WHERE EMPNO IN (SELECT A.EMPNO FROM EMP A
INTERSECT SELECT B.MGR FROM EMP B)
//Pointless to do all of that though when a simple query can get us the results.
144) Display the name of employees who joined the company on the same date?
OR
SELECT E.ENAME FROM EMP E WHERE HIREDATE IN(SELECT HIREDATE FROM EMP WHERE
EMPNO<>E.EMPNO);
145) Display the manager who is having maximum number of employees working under
him?
SQL>SELECT E1.ENAME FROM (SELECT MGR,COUNT(MGR) FROM EMP GROUP BY MGR ORDER
BY
COUNT(MGR) DESC) X,EMP E1 WHERE X.MGR=E1.EMPNO AND ROWNUM = 1;
OR
146) List out the employee name and salary increased by 15% and express as whole number
of Dollars?
147) Produce the output of the emp table “EMPLOYEE_AND_JOB” for ename and job ?
148) List of employees with hiredate in the format of ‘June 4 1988′?
149) Print list of employees displaying ‘Just salary’ if sal more than 1500, if exactly 1500
display ‘on target’, if less than 1500 display below 1500?
SQL> SELECT ENAME, (CASE WHEN SAL>1500 THEN ‘BELOW_TARGET’ WHEN SAL=1500
THEN ‘ON_TARGET’ WHEN SAL<1500 THEN ‘LESS THAN TARGET’ END ) AS SALCOND FROM
EMP
150) Given a string of the format ‘nn/nn’ . Verify that the first and last 2 characters are
numbers .And that the middle character is ‘/’ Print the expressions ‘Yes’ IF valid ‘NO’ of not
valid . Use the following values to test your solution’12/54′,01/1a,’99/98′?