SQL Queries
1)Display the details of all employees
a)select * from emp;
2)Display the depart informaction from
department table
a)select * from dept;
3)Display the name and job for all the employees
a)select ename,job from emp;
4)Display the name and salary for all the
employees
a)select ename,sal from emp;
5)Display the employee no and totalsalary for all
the employees
a)select empno,sal+comm as total from emp
group by empno;
6)Display the employee name and annual salary
for all employees.
a)select ename,sal * 12 as annualsalary from
emp;
7)Display the names of all the employees who are
working in depart
number 10.
a)select emame from emp where deptno=10;
8)Display the names of all the employees who are
working as clerks and
drawing a salary more than 3000.
a)select ename from emp where job='CLERKS'
and sal>3000;
9)Display the employee number and name who
are earning comm.
a)select empno,ename from emp where comm is
not null;
10)Display the employee number and name who
do not earn any comm.
a)select empno,ename from emp where comm is
null;
11)display the names of employees who are
working as clerks,salesman or
analyst and drawing a salary more than 3000.
A)select ename from emp where job='CLERK' OR
JOB='SALESMAN' OR
JOB='ANALYST' AND SAL>3000;
12)display the names of the employees who are
working in the company
for the past 5 years;
a)select ename from emp where
to_char(sysdate,'YYYY')-
to_char(hiredate,'YYYY')>=5;
13)Display the list of employcees who have joined
the company before
30-JUN-90 or after 31-DEC-90.
a)select ename from emp where hiredate < '30-
JUN-1990' or hiredate >
'31-DEC-90';
14)Display current Date.
a)select sysdate from dual;
15)Display the list of all users in your
database(use catalog table).
a)select username from all_users;
16)Display the names of all tables from current
user;
a)select tname from tab;
17)Display the name of the current user.
a)show user
18)Display the names of employees working in
depart number 10 or 20 or
40 or employees working as CLERKS, SALESMAN
or ANALYST.
a) Select ename from emp where deptno
in(10,20,40) or job
in('CLERKS','SALESMAN','ANALYST');
19) Display the names of employees whose name
starts with alphabet S.
a)select ename from emp where ename like 'S%';
20) Display the Employee names for employees
whose name ends with Alphabet S.
a) Select ename from emp where ename like
'%S';
21) Display the names of employees whose
names have second alphabet A in their names.
a) Select ename from EMP where ename like '_A
%';
22) select the names of the employee whose
names is exactly five
Characters in length.
a) select ename from emp where
length(ename)=5;
23) Display the names of the employee who are
not working as MANAGERS.
a) Select ename from emp where job not in
('MANAGER');
24)Display the names of the employee who are
not working as SALESMAN OR CLERK OR
ANALYST.
A)select ename from emp where job not
in('SALESMAN','CLERK','ANALYST');
25) Display all rows from EMP table. The system
should wait after every Screen full of information.
a) Set pause on
26) Display the total number of employee working
in the company.
a) Select count (*) from EMP;
27) Display the total salary beiging paid to all
employees.
a)select sum(sal) from emp;
28)Display the maximum salary from emp table.
a)select max(sal) from emp;
29)Display the minimum salary from emp table.
a)select min(sal) from emp;
30)Display the average salary from emp table.
a)select avg(sal) from emp;
31)Display the maximum salary being paid to
CLERK.
a)select max(sal) from emp where job='CLERK';
32)Display the maximum salary being paid to
depart number 20.
a)select max(sal) from emp where deptno=20;
33)Display the minimum salary being paid to any
SALESMAN.
a)select min(sal) from emp where
job='SALESMAN';
34)Display the average salary drawn by
MANAGERS.
a)select avg(sal) from emp where
job='MANAGER';
35)Display the total salary drawn by ANALYST
working in depart number
40.
a)select sum(sal) from emp where job='ANALYST'
and deptno=40;
36)Display the names of the employee in order of
salary i.e the name of
the employee earning lowest salary should salary
appear first.
a)select ename from emp order by sal;
37)Display the names of the employee in
descending order of salary.
a)select ename from emp order by sal desc;
38)Display the names of the employee in order of
employee name.
a)select ename from emp order by ename;
39)Display empno,ename,deptno,sal sort the
output first base on name
and within name by deptno and with in deptno by
sal.
a)selectempno,ename,deptno,sal fromemp
order byename,deptno,sal
40)Display the name of the employee along with
their annual salary(sal*
12).The name
of the employee earning highest annual salary
should apper first.
a)select ename,sal*12 from emp order by sal
desc;
41)Display name,salary,hra,pf,da,total salary for
each employee. The
output 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.
a)select ename,sal,sal/100*15 as hra,sal/100*5 as
pf,sal/100*10 as
da,sal+sal/100*15+sal/100*10-sal/100*5 as total
from emp;
42)Display depart numbers and total number of
employees working in each
department.
a)select deptno,count(deptno)from emp group by
deptno;
43)Display the various jobs and total number of
employees within each
job group.
a)select job,count(job)from emp group by job;
44)Display the depart numbers and total salary
for each department.
a)select deptno,sum(sal) from emp group by
deptno;
45)Display the depart numbers and max salary
for each department.
a)select deptno,max(sal) from emp group by
deptno;
46)Display the various jobs and total salary for
each job
a)select job,sum(sal) from emp group by job;
47)Display the various jobs and total salary for
each job
a)select job,min(sal) from emp group by job;
48)Display the depart numbers with more than
three employees in each
dept.
a)select deptno,count(deptno) from emp group by
deptno having
count(*)>3;
49)Display the various jobs along with total salary
for each of the
jobs where total salary is greater than 40000.
a)select job,sum(sal) from emp group by job
having sum(sal)>40000;
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.
a)select job,count(empno) from emp group by job
having count(job)>3
51)Display the name of the empployee who earns
highest salary.
a)select ename from emp where sal=(select
max(sal) from emp);
52)Display the employee number and name for
employee working as clerk
and earning highest salary among clerks.
a)select empno,ename from emp where where
job='CLERK' and sal=(select
max(sal) from emp where job='CLERK');
53)Display the names of salesman who earns a
salary more than the
highest salary of any clerk.
a)select ename,sal from emp where
job='SALESMAN' and sal>(select
max(sal) from emp where job='CLERK');
54)Display the names of clerks who earn a salary
more than the lowest
salary of any salesman.
A)select ename from emp where job='CLERK' and
sal>(select min(sal) from
emp where job='SALESMAN');
55)Display the names of employees who earn a
salary more than that of
Jones or that of salary grether than that of scott.
a)select ename,sal from emp where sal>
(select sal from emp where ename='JONES')and
sal> (select sal from emp
where ename='SCOTT');
56)Display the names of the employees who earn
highest salary in their
respective departments.
a)select ename,sal,deptno from emp where sal
in(select max(sal) from
emp group by deptno);
57)Display the names of the employees who earn
highest salaries in
their respective job groups.
a)select ename,sal,job from emp where sal
in(select max(sal) from emp
group by job)
58)Display the employee names who are working
in accounting department.
a)select ename from emp where deptno=(select
deptno from dept where
dname='ACCOUNTING')
59)Display the employee names who are working
in Chicago.
a)select ename from emp where deptno=(select
deptno from dept where
LOC='CHICAGO')
60)Display the Job groups having total salary
greater than the maximum
salary for managers.
a)SELECT JOB,SUM(SAL) FROM EMP GROUP BY JOB
HAVING SUM(SAL)>(SELECT
MAX(SAL) FROM EMP WHERE JOB='MANAGER');
61)Display the names of employees from
department number 10 with salary
grether than that of any employee working in
other department.
a)select ename from emp where deptno=10 and
sal>any(select sal from emp
where deptno not in 10).
62)Display the names of the employees from
department number 10 with
salary greater than that of all employee working
in other departments.
a)select ename from emp where deptno=10 and
sal>all(select sal from emp
where deptno not in 10).
63)Display the names of the employees in
Uppercase.
a)select upper(ename)from emp
64)Display the names of the employees in
Lowecase.
a)select lower(ename)from emp
65)Display the names of the employees in
Propercase.
a)select initcap(ename)from emp;
66)Display the length of Your name using
appropriate function.
a)select length('name') from dual
67)Display the length of all the employee names.
a)select length(ename) from emp;
68)select name of the employee concatenate with
employee number.
select ename||empno from emp;
69)User approprate function and extract 3
characters starting from 2
characters from the following string 'Oracle'. i.e
the out put should be
'ac'.
a)select substr('oracle',3,2) from dual
70)Find the First occurance of character 'a' from
the following string
i.e 'Computer Maintenance Corporation'.
a)SELECT INSTR('Computer Maintenance
Corporation','a',1) FROM DUAL
71)Replace every occurance of alphabhet A with
B in the string
Allens(use translate function)
a)select translate('Allens','A','B') from dual
72)Display the informaction from emp
table.Where job manager is found
it should be displayed as boos(Use replace
function).
a)select replace(JOB,'MANAGER','BOSS') FROM
EMP;
73)Display empno,ename,deptno from emp
table.Instead of display
department numbers display the related
department name(Use decode function).
a)select
empno,ename,decode(deptno,10,'ACCOUNTING',2
0,'RESEARCH',30,'SALES',40,'OPRATIONS') from
emp;
74)Display your age in days.
a)select to_date(sysdate)-to_date('10-sep-
77')from dual
75)Display your age in months.
a)select months_between(sysdate,'10-sep-77')
from dual
76)Display the current date as 15th Augest Friday
Nineteen Ninety
Saven.
a)select to_char(sysdate,'ddth Month day year')
from dual
77)Display the following output for each row from
emp table.
78)scott has joined the company on wednesday
13th August ninten nintey.
a)select ENAME||' HAS JOINED THE COMPANY ON
'||to_char(HIREDATE,'day
ddth Month year') from EMP;
79)Find the date for nearest saturday after
current date.
a)SELECT NEXT_DAY(SYSDATE,'SATURDAY')FROM
DUAL;
80)display current time.
a)select to_char(sysdate,'hh:MM:ss') from dual.
81)Display the date three months Before the
current date.
a)select add_months(sysdate,3) from dual;
82)Display the common jobs from department
number 10 and 20.
a)select job from emp where deptno=10 and job
in(select job from emp
where deptno=20);
83)Display the jobs found in department 10 and
20 Eliminate duplicate
jobs.
a)select distinct(job) from emp where deptno=10
or deptno=20
or
select distinct(job) from emp where deptno
in(10,20);
84)Display the jobs which are unique to
department 10.
a)select distinct(job) from emp where deptno=10
85)Display the details of those who do not have
any person working
under them.
a)select e.ename from emp,emp e where
emp.mgr=e.empno group by e.ename
having count(*)=1;
86)Display the details of those employees who
are in sales department
and grade is 3.
a)
select * from emp where deptno=(select
deptno from dept where
dname='SALES')and
sal between(select losal from salgrade
where grade=3)and
(select hisal from salgrade where
grade=3);
87)Display those who are not managers and who
are managers any one.
i)display the managers names
a)select distinct(m.ename) from emp e,emp m
where m.empno=e.mgr;
ii)display the who are not managers
a)select ename from emp where ename not
in(select distinct(m.ename)
from emp e,emp m where m.empno=e.mgr);
88)Display those employee whose name contains
not less than 4
characters.
a)select ename from emp where
length(ename)>4;
89)Display those department whose name start
with "S" while the
location name ends with "K".
a)select dname from dept where dname like 'S%'
and loc like '%K';
90)Display those employees whose manager
name is JONES.
a)select p.ename from emp e,emp p where
e.empno=p.mgr and
e.ename='JONES';
91)Display those employees whose salary is more
than 3000 after giving
20% increment.
a)select ename,sal from emp where
(sal+sal*.2)>3000;
92)Display all employees while their dept names;
s)select ename,dname from emp,dept where
emp.deptno=dept.deptno
93)Display ename who are working in sales dept.
a)select ename from emp where deptno=(select
deptno from dept where
dname='SALES');
94)Display employee name,deptname,salary and
comm for those sal in
between 2000 to 5000 while location is chicago.
a)select ename,dname,sal,comm from emp,dept
where sal between 2000 and
5000 and loc='CHICAGO' and
emp.deptno=dept.deptno;
95)Display those employees whose salary greter
than his manager salary.
a)select p.ename from emp e,emp p where
e.empno=p.mgr and p.sal>e.sal
96)Display those employees who are working in
the same dept where his
manager is work.
a)select p.ename from emp e,emp p where
e.empno=p.mgr and
p.deptno=e.deptno;
97)Display those employees who are not working
under any manager.
a)select ename from emp where mgr is null
98)Display grade and employees name for the
dept no 10 or 30 but grade
is not 4 while joined the company before 31-dec-
82.
a)select ename,grade from emp,salgrade where
sal between losal and hisal and deptno in(10,30)
and grade<>4 and hiredate<'31-DEC-82';
99)Update the salary of each employee by 10%
increment who are not eligiblw for commission.
a)update emp set sal=sal+sal*10/100 where
comm is null;
100)SELECT those employee who joined the
company before 31-dec-82 while their dept
location is newyork or Chicago.
a)SELECT EMPNO,ENAME,HIREDATE,DNAME,LOC
FROM EMP,DEPT WHERE
(EMP.DEPTNO=DEPT.DEPTNO)AND
HIREDATE <'31-DEC-82' AND DEPT.LOC
IN('CHICAGO','NEW YORK');
101)DISPLAY EMPLOYEE
NAME,JOB,DEPARTMENT,LOCATION FOR ALL WHO
ARE
WORKING AS MANAGER?
A)select ename,JOB,DNAME,LOCATION from
emp,DEPT where mgr is not null;
102)dISPLAY THOSE EMPLOYEES WHOSE
MANAGER NAME IS JONES? --[AND ALSO
DISPLAY THEIR MANAGER NAME]?
A) SELECT P.ENAME FROM EMP E, EMP P WHERE
E.EMPNO=P.MGR AND
E.ENAME='JONES';
103)Display name and salary of ford if his salary
is equal to hisal of
his grade
a)select ename,sal,grade from emp,salgrade
where sal between losal and
hisal
and ename ='FORD' AND HISAL=SAL;
104)Display employee name,job,depart name
,manager name,his grade and
make out an under department wise?
a)SELECT
E.ENAME,E.JOB,DNAME,EMP.ENAME,GRADE FROM
EMP,EMP
E,SALGRADE,DEPT
WHERE EMP.SAL BETWEEN LOSAL AND HISAL
AND EMP.EMPNO=E.MGR AND
EMP.DEPTNO=DEPT.DEPTNO ORDER BY DNAME
105)List out all employees name,job,salary,grade
and depart name for every one in the company
except 'CLERK'.Sort on salary display the highest
salary?
a)SELECT ENAME,JOB,DNAME,SAL,GRADE FROM
EMP,SALGRADE,DEPT WHERE
SAL BETWEEN LOSAL AND HISAL AND
EMP.DEPTNO=DEPT.DEPTNO AND JOB NOT
IN('CLERK')ORDER BY SAL ASC;
106)Display the employee name,job and his
manager.Display also employee who are without
manager?
a)select e.ename,e.job,eMP.ename AS Manager
from emp,emp e where emp.empno(+)=e.mgr
107)Find out the top 5 earners of company?
a)SELECT DISTINCT SAL FROM EMP E WHERE
5>=(SELECT COUNT(DISTINCT SAL)
FROM EMP A WHERE A.SAL>=E.SAL)ORDER BY
SAL DESC;
108)Display name of those employee who are
getting the highest salary?
a)select ename from emp where sal=(select
max(sal) from emp);
109)Display those employee whose salary is
equal to average of maximum
and minimum?
a)select ename from emp where sal=(select
max(sal)+min(sal)/2 from
emp);
110)Select count of employee in each department
where count greater than 3?
a)select count(*) from emp group by deptno
having count(deptno)>3
111)Display dname where at least 3 are working
and display only
department name?
a)select distinct d.dname from dept d,emp e
where d.deptno=e.deptno and
3>any (select count(deptno) from emp group by
deptno)
112)Display name of those managers name
whose salary is more than average salary of his
company?
a)SELECT E.ENAME,EMP.ENAME FROM EMP,EMP E
WHERE EMP.EMPNO=E.MGR AND
E.SAL>(SELECT AVG(SAL) FROM EMP);
113)Display those managers name whose salary
is more than average salary of his employee?
a)SELECT DISTINCT EMP.ENAME FROM EMP,EMP E
WHERE E.SAL <(SELECT AVG(EMP.SAL) FROM
EMP
WHERE EMP.EMPNO=E.MGR GROUP BY
EMP.ENAME) AND EMP.EMPNO=E.MGR;
114)Display employee name,sal,comm and net
pay for those employee whose net pay is greter
than or equal to any other employee salary of
the company?
a)select ename,sal,comm,sal+nvl(comm,0) as
NetPay from emp where sal+nvl(comm,0) >any
(select sal from emp)
115)Display those employees whose salary is less
than his manager but more than salary of any
other manager?
a)
116)Display all employees names with total sal of
company with each
employee name?
a)SELECT ENAME,(SELECT SUM(SAL) FROM EMP)
FROM EMP;
117)Find out last 5(least)earners of the
company.?
a)SELECT DISTINCT SAL FROM EMP E WHERE
5>=(SELECT COUNT(DISTINCT SAL)
FROM EMP A WHERE A.SAL<=E.SAL)ORDER BY
SAL DESC;
118)Find out the number of employees whose
salary is greater than their manager salary?
a)SELECT E.ENAME FROM EMP ,EMP E WHERE
EMP.EMPNO=E.MGR AND
EMP.SAL<E.SAL;
119)Display those manager who are not working
under president but they are working under any
other manager?
a)
120)Display those department where no
employee working?
a)select dname from emp,dept where
emp.deptno not in(emp.deptno)
121)delete those records from emp table whose
deptno not available in dept table.
a)
122)Display those enames whose salary is out of
the grade available in salgrade table.
a)
123)Display employee name,sal,comm and whose
net pay is greater than
any other in the company?
a)
124)Display name of those employee who are
going to retrie 31-DEC-99.
if the maximum job period is 30 years?
a)
125)Display those employee whose salary is ODD
value?
a)select * from emp where sal<0;
126)Display those employee whose salary
contains alleast 3 digits?
a)select * from emp where length(sal)>=3;
127)Display those employee who joined in the
company in the month of
Dec?
a)select ename from emp where
to_char(hiredate,'MON')='DEC';
128)Display those employees whose name
contains "A"?
a)select ename from emp where
instr(ename,'A')>0;
or
select ename from emp where ename like('%A
%');
129)Display those employee whose deptno is
available in salary?
a)select emp.ename from emp, emp e where
emp.sal=e.deptno;
130)Display those employee whose first 2
characters from hiredate -last
2 characters of salary?
a)select ename,SUBSTR(hiredate,1,2)||ENAME||
substr(sal,-2,2) from emp
131)Display those employee whose 10% of salary
is equal to the year of
joining?
a)select ename from emp where
to_char(hiredate,'YY')=sal*0.1;
132)Display those employee who are working in
sales or research?
a)SELECT ENAME FROM EMP WHERE DEPTNO
IN(SELECT DEPTNO FROM DEPT WHERE
DNAME IN('SALES','RESEARCH'));
133)Display the grade of jones?
a)SELECT ENAME,GRADE FROM EMP,SALGRADE
WHERE SAL BETWEEN LOSAL AND
HISAL AND Ename='JONES';
134)Display those employees who joined the
company before 15 of the
month?
a)select ename from emp where
to_char(hiredate,'DD')<15;
135)Display those employee who has joined
before 15th of the month.
a)select ename from emp where
to_char(hiredate,'DD')<15;
136)Delete those records where no of employees
in a particular
department is less than 3.
a)delete from emp where deptno=(select deptno
from emp
group by deptno having count(deptno)<3);
137)Display the department name the no of
characters of which
is equal to no of employee in any other
department.
a)
138)Display the name of the department where
no employee working.
a)
139)Display those employees who are working as
manager.
a)
140)Count the no of employees who are working
as manager(using set
operations).
a)
141)Display the name of the dept those employee
who joined the company
on the same date?
a)
142)Display those employees whose grade is
equal to any number of sal
but not equal to first number of sal?
a)
143)Count the no of empployee working as
manager using set operaction?
a)
144)display the name of the employees who
joined the same date.
a)
145)Display the manager who is having maximum
number of employees working under him?
a)
146)list out employee name and salary increased
by 15% and expressed as whole number of
Dollars?
a)
147)Produce the output of the emp table "EMPLOYEE AND JOB" for ename and job? a)
148)List all employee with hiredate in the format
'june 4 1988'?
a)
149)Print lost of employees displaying "just
salary" if more than 1500
if exactly 1500 display 'On target' if less than
1500 Display below 1500?
A)select ename,sal,(case when sal>1500 then
'Below_target' when
sal=1500 then 'On_targer' when sal<1500 then
'less than target' else 'kkkkk' end )from emp
150)WHICH query to calcuate the length of time
any employee has been with the company?
151)Give 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
exprection 'Yes' if valid 'No' of not valid Use the
following values to test your soluction '$12/54(Not
clear).
a)
152)Employee hire on 15th of any month are paid
on the last Friday of that month. Those hired after
15th are paid the last Friday of the following
month.Print a list of employees.their hire date
and first pay date scort those whose salary
contains first digits of their deptno?
a)
select
ename,hiredate,last_day(next_day(hiredate,'FRID
AY')),deptno,
(case when to_char(hiredate,'DD')<=15 then
last_day(next_day(hiredate,'FRIDAY'))
when to_char(hiredate,'DD')>15 then
last_day(next_day(add_months(hiredate,1),'FRIDA
Y'))
end
)from emp order by substr(sal,0,2) ;
153)Display those manager who are getting less
than his employee
salary?
a)
154)Print the details of all the employees who are
Sub-ordinate to
BLAKE?
a)select emp.ename from emp, emp e where
emp.mgr=e.empno and
e.ename='BLAKE';
155)Display those who are working as manager
using CO-relate sub-query?
a)
156)Display those employee whose manager
name is jones and also with his manager name?
a)
157)Define variable representing the expression
used to calculate on
employee total Annual Remunatation?
a)
158)Use the variable in a statement which finds
all employees who can earn $30,000 a year or
more?
a)
159)Find out how many managers are there with
out listing them?
a)
160)Find out the average salary and average total
remuneration for each job type remember sales
man earn commission?
a)
161)Check whether all employees number are
indeed unique?
a)
162)List out the lowest paid employees working
for each manager exclude any groups where
minimum salary is less than Rs.1000 Sort the
output by salary?
a)
163)List ename,job,annual sal,deptno,dname and
grade who earn $36,000 a year or who are not
Clerks?
a)
164)Find out the job that was failedin the first half
of 1983 and same
job that was failed during the same period on
1984?
a)
165)Find out the employees who joined the
company before their manager?
a)
166)List out all the employees by name and
number along with their
manager's name and number also display %NG
who has no manager?
a)
167)Find out the employee who earned the
highest salary in each job
type Sort in desending salary order?
a)
168)Find out the employees who earned the
minimum salary for their job in Assending order?
a)
169)Find out the most resently hired employees
in each department Order by hiredate?
a)
170)Display ename,salary and deptno for each
employee who earn a salary greater than the
average for then department order by deptno?
a)
171)Display the department where there are no
employees?
a)
172)Display the department no with highest
annual remunaration bill as compensation?
a)
173)In which year did most people join the
company Display the year and number of
employees?
a)
174)Display the average salary figure for the
department?
a)select avg(SAL) from emp group by deptno
175)Write a query of display against the row of
the most recently hired employees Display ename
Hiredate and column max date showing;
a)
176)Display employee who can earn more than
lowest salary in department no 30?
a)
177)Find employees who can earn more than
every employee in deptno?
a)
178)Select dept name deptno and sum of salary?
a)
179)Find out average salary and average total
remainders for each job type?
a)
180)Find all departments which have more than 3
employees?
a)
181)Check whether employees number are
unique?
a)
182)List lowest paid employees working for each
manager exclude any
groups where the minimum salary less than 1000.
Sort the output by
salary?
a)
183)If the pay day is next friday after 15th and
30th of every
month.what is the next pay day from their hire
date for employee in emp table?
a)
184)If an employee is taken by you today in your
organisation.
And it is a policy in your company to have a
review after 9 months the
joined date (and of 1st of next month after 9
months )how many days from today your
employees has To wait for a review?
a)
185)Display employee name and his salary whose
salary is greater than highest average of
department number?
a)SELECT SAL FROM EMP WHERE SAL>(SELECT
MAX(AVG(SAL)) FROM EMP GROUP BY
DEPTNO);
186)Display the 10th record of emp table(without
using rowid)
a)
SELECT * FROM EMP WHERE
ROWNUM<11
MINUS
SELECT * FROM EMP WHERE
ROWNUM<10
187)Display the half of the ename's in upper case
and remaining
lowercase?
a)
SELECT
SUBSTR(LOWER(ENAME),1,3)||
SUBSTR(UPPER(ENAME),3,LENGTH(ENAME)) FROM
EMP;
188.
Display the 10th record of emp table
without using group by and rowid?
A)
SELECT * FROM EMP WHERE
ROWNUM<11
MINUS
SELECT * FROM EMP WHERE
ROWNUM<10
189.
Delete the 10th record of emp table.
A)
DELETE FROM EMP WHERE
EMPNO=(SELECT EMPNO FROM EMP WHERE
ROWNUM<11
MINUS
SELECT EMPNO FROM EMP WHERE
ROWNUM<10)
190.
Create a copy of emp table;
a)
create table new_table as select * from
emp where 1=2;
191.
Select ename if ename exists more than
once.
a)
select ename from emp e group by
ename having count(*)>1;
192.
Display all enames in reverse order?
(SMITH:HTIMS).
a)
SELECT REVERSE(ENAME)FROM EMP;
193.
Display those employee whose joining of
month and grade is equal.
A)
SELECT ENAME FROM EMP WHERE SAL
BETWEEN(SELECT LOSAL FROM SALGRADE
WHERE GRADE=TO_CHAR(HIREDATE,'MM')) AND
(SELECT HISAL FROM SALGRADE WHERE
GRADE=TO_CHAR(HIREDATE,'MM'));
194.
Display those employee whose joining
DATE is available in deptno.
A)
SELECT ENAME FROM EMP WHERE
TO_CHAR(HIREDATE,'DD')=DEPTNO
195.
Display those employees name as
follows
A ALLEN
B BLAKE
A)
SELECT SUBSTR(ENAME,1,1),ENAME
FROM EMP;
196.
List out the employees
ename,sal,PF(20% OF SAL) from emp;
A)
SELECT ENAME,SAL,SAL*.2 AS PF FROM
EMP;
197.
Display RSPS from emp without using
updating inserting.
A)
198.
Create table emp with only one column
empno;
A)
create table emp as select empno from
emp where 1=2;
199.
Add this column to emp table ename
vrachar2(20).
a)
alter table emp add(ename
varchar2(20));
200.
Oops I forgot give the primary key
constraint. Add in now.
a)
alter table emp add primary
key(empno);
201.
Now increase the length of ename
column to 30 characters.
a)
alter table emp modify(ename
varchar2(30));
202.
Add salary column to emp table.
alter table emp add(sal number(10));
203.
I want to give a validation saying that
salary cannot be greater
10,000(note give a name to this constraint)
a)
alter table emp add constraint chk_001
check(sal<=10000)
204.
For the time being I have decided that I
will not impose this
validation.
My boss has agreed to pay more than
10,000.
a)
again alter the table or drop constraint
with
alter table emp drop constraint
chk_001 (or)Disable the constraint by
using
a)
119)How many different courses are mentioned in
the studies table.
a)
120)Display the names of the programmers
whose names contain 2
concurrence of the.
a)
121)Display the names of programmers whose
names contaion upto 5
characters.
a)
122)How many female programmers knowing
cobol have more than 2 years
experience.
a)
123)What is the length of the shortest name in
programmer table.
a)
124)What is the average development cost of a
package developed in
cobol.
a)
125)Display the name,sex,dob(dd/mm/yy
format)for all programmers,
without using conversion function.
a)
126)Who are the programmers who were born on
the last day of the month.
a)
127)What is the amount paid in salaries of the
male programmers who don't know cobol.
a)
128)Display the Title______________________And
______________in descending order of differences.
a)
129)Display the names of the packages whose
names contains more than 1 word.
a)
130)Display the name,job,odj of those month of
birth & month of joining are the same.
a)
1)Display the details of all employees
a)select * from emp;
2)Display the depart informaction from
department table
a)select * from dept;
3)Display the name and job for all the employees
a)select ename,job from emp;
4)Display the name and salary for all the
employees
a)select ename,sal from emp;
5)Display the employee no and totalsalary for all
the employees
a)select empno,sal+comm as total from emp
group by empno;
6)Display the employee name and annual salary
for all employees.
a)select ename,sal * 12 as annualsalary from
emp;
7)Display the names of all the employees who are
working in depart
number 10.
a)select emame from emp where deptno=10;
8)Display the names of all the employees who are
working as clerks and
drawing a salary more than 3000.
a)select ename from emp where job='CLERKS'
and sal>3000;
9)Display the employee number and name who
are earning comm.
a)select empno,ename from emp where comm is
not null;
10)Display the employee number and name who
do not earn any comm.
a)select empno,ename from emp where comm is
null;
11)display the names of employees who are
working as clerks,salesman or
analyst and drawing a salary more than 3000.
A)select ename from emp where job='CLERK' OR
JOB='SALESMAN' OR
JOB='ANALYST' AND SAL>3000;
12)display the names of the employees who are
working in the company
for the past 5 years;
a)select ename from emp where
to_char(sysdate,'YYYY')-
to_char(hiredate,'YYYY')>=5;
13)Display the list of employcees who have joined
the company before
30-JUN-90 or after 31-DEC-90.
a)select ename from emp where hiredate < '30-
JUN-1990' or hiredate >
'31-DEC-90';
14)Display current Date.
a)select sysdate from dual;
15)Display the list of all users in your
database(use catalog table).
a)select username from all_users;
16)Display the names of all tables from current
user;
a)select tname from tab;
17)Display the name of the current user.
a)show user
18)Display the names of employees working in
depart number 10 or 20 or
40 or employees working as CLERKS, SALESMAN
or ANALYST.
a) Select ename from emp where deptno
in(10,20,40) or job
in('CLERKS','SALESMAN','ANALYST');
19) Display the names of employees whose name
starts with alphabet S.
a)select ename from emp where ename like 'S%';
20) Display the Employee names for employees
whose name ends with Alphabet S.
a) Select ename from emp where ename like
'%S';
21) Display the names of employees whose
names have second alphabet A in their names.
a) Select ename from EMP where ename like '_A
%';
22) select the names of the employee whose
names is exactly five
Characters in length.
a) select ename from emp where
length(ename)=5;
23) Display the names of the employee who are
not working as MANAGERS.
a) Select ename from emp where job not in
('MANAGER');
24)Display the names of the employee who are
not working as SALESMAN OR CLERK OR
ANALYST.
A)select ename from emp where job not
in('SALESMAN','CLERK','ANALYST');
25) Display all rows from EMP table. The system
should wait after every Screen full of information.
a) Set pause on
26) Display the total number of employee working
in the company.
a) Select count (*) from EMP;
27) Display the total salary beiging paid to all
employees.
a)select sum(sal) from emp;
28)Display the maximum salary from emp table.
a)select max(sal) from emp;
29)Display the minimum salary from emp table.
a)select min(sal) from emp;
30)Display the average salary from emp table.
a)select avg(sal) from emp;
31)Display the maximum salary being paid to
CLERK.
a)select max(sal) from emp where job='CLERK';
32)Display the maximum salary being paid to
depart number 20.
a)select max(sal) from emp where deptno=20;
33)Display the minimum salary being paid to any
SALESMAN.
a)select min(sal) from emp where
job='SALESMAN';
34)Display the average salary drawn by
MANAGERS.
a)select avg(sal) from emp where
job='MANAGER';
35)Display the total salary drawn by ANALYST
working in depart number
40.
a)select sum(sal) from emp where job='ANALYST'
and deptno=40;
36)Display the names of the employee in order of
salary i.e the name of
the employee earning lowest salary should salary
appear first.
a)select ename from emp order by sal;
37)Display the names of the employee in
descending order of salary.
a)select ename from emp order by sal desc;
38)Display the names of the employee in order of
employee name.
a)select ename from emp order by ename;
39)Display empno,ename,deptno,sal sort the
output first base on name
and within name by deptno and with in deptno by
sal.
a)selectempno,ename,deptno,sal fromemp
order byename,deptno,sal
40)Display the name of the employee along with
their annual salary(sal*
12).The name
of the employee earning highest annual salary
should apper first.
a)select ename,sal*12 from emp order by sal
desc;
41)Display name,salary,hra,pf,da,total salary for
each employee. The
output 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.
a)select ename,sal,sal/100*15 as hra,sal/100*5 as
pf,sal/100*10 as
da,sal+sal/100*15+sal/100*10-sal/100*5 as total
from emp;
42)Display depart numbers and total number of
employees working in each
department.
a)select deptno,count(deptno)from emp group by
deptno;
43)Display the various jobs and total number of
employees within each
job group.
a)select job,count(job)from emp group by job;
44)Display the depart numbers and total salary
for each department.
a)select deptno,sum(sal) from emp group by
deptno;
45)Display the depart numbers and max salary
for each department.
a)select deptno,max(sal) from emp group by
deptno;
46)Display the various jobs and total salary for
each job
a)select job,sum(sal) from emp group by job;
47)Display the various jobs and total salary for
each job
a)select job,min(sal) from emp group by job;
48)Display the depart numbers with more than
three employees in each
dept.
a)select deptno,count(deptno) from emp group by
deptno having
count(*)>3;
49)Display the various jobs along with total salary
for each of the
jobs where total salary is greater than 40000.
a)select job,sum(sal) from emp group by job
having sum(sal)>40000;
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.
a)select job,count(empno) from emp group by job
having count(job)>3
51)Display the name of the empployee who earns
highest salary.
a)select ename from emp where sal=(select
max(sal) from emp);
52)Display the employee number and name for
employee working as clerk
and earning highest salary among clerks.
a)select empno,ename from emp where where
job='CLERK' and sal=(select
max(sal) from emp where job='CLERK');
53)Display the names of salesman who earns a
salary more than the
highest salary of any clerk.
a)select ename,sal from emp where
job='SALESMAN' and sal>(select
max(sal) from emp where job='CLERK');
54)Display the names of clerks who earn a salary
more than the lowest
salary of any salesman.
A)select ename from emp where job='CLERK' and
sal>(select min(sal) from
emp where job='SALESMAN');
55)Display the names of employees who earn a
salary more than that of
Jones or that of salary grether than that of scott.
a)select ename,sal from emp where sal>
(select sal from emp where ename='JONES')and
sal> (select sal from emp
where ename='SCOTT');
56)Display the names of the employees who earn
highest salary in their
respective departments.
a)select ename,sal,deptno from emp where sal
in(select max(sal) from
emp group by deptno);
57)Display the names of the employees who earn
highest salaries in
their respective job groups.
a)select ename,sal,job from emp where sal
in(select max(sal) from emp
group by job)
58)Display the employee names who are working
in accounting department.
a)select ename from emp where deptno=(select
deptno from dept where
dname='ACCOUNTING')
59)Display the employee names who are working
in Chicago.
a)select ename from emp where deptno=(select
deptno from dept where
LOC='CHICAGO')
60)Display the Job groups having total salary
greater than the maximum
salary for managers.
a)SELECT JOB,SUM(SAL) FROM EMP GROUP BY JOB
HAVING SUM(SAL)>(SELECT
MAX(SAL) FROM EMP WHERE JOB='MANAGER');
61)Display the names of employees from
department number 10 with salary
grether than that of any employee working in
other department.
a)select ename from emp where deptno=10 and
sal>any(select sal from emp
where deptno not in 10).
62)Display the names of the employees from
department number 10 with
salary greater than that of all employee working
in other departments.
a)select ename from emp where deptno=10 and
sal>all(select sal from emp
where deptno not in 10).
63)Display the names of the employees in
Uppercase.
a)select upper(ename)from emp
64)Display the names of the employees in
Lowecase.
a)select lower(ename)from emp
65)Display the names of the employees in
Propercase.
a)select initcap(ename)from emp;
66)Display the length of Your name using
appropriate function.
a)select length('name') from dual
67)Display the length of all the employee names.
a)select length(ename) from emp;
68)select name of the employee concatenate with
employee number.
select ename||empno from emp;
69)User approprate function and extract 3
characters starting from 2
characters from the following string 'Oracle'. i.e
the out put should be
'ac'.
a)select substr('oracle',3,2) from dual
70)Find the First occurance of character 'a' from
the following string
i.e 'Computer Maintenance Corporation'.
a)SELECT INSTR('Computer Maintenance
Corporation','a',1) FROM DUAL
71)Replace every occurance of alphabhet A with
B in the string
Allens(use translate function)
a)select translate('Allens','A','B') from dual
72)Display the informaction from emp
table.Where job manager is found
it should be displayed as boos(Use replace
function).
a)select replace(JOB,'MANAGER','BOSS') FROM
EMP;
73)Display empno,ename,deptno from emp
table.Instead of display
department numbers display the related
department name(Use decode function).
a)select
empno,ename,decode(deptno,10,'ACCOUNTING',2
0,'RESEARCH',30,'SALES',40,'OPRATIONS') from
emp;
74)Display your age in days.
a)select to_date(sysdate)-to_date('10-sep-
77')from dual
75)Display your age in months.
a)select months_between(sysdate,'10-sep-77')
from dual
76)Display the current date as 15th Augest Friday
Nineteen Ninety
Saven.
a)select to_char(sysdate,'ddth Month day year')
from dual
77)Display the following output for each row from
emp table.
78)scott has joined the company on wednesday
13th August ninten nintey.
a)select ENAME||' HAS JOINED THE COMPANY ON
'||to_char(HIREDATE,'day
ddth Month year') from EMP;
79)Find the date for nearest saturday after
current date.
a)SELECT NEXT_DAY(SYSDATE,'SATURDAY')FROM
DUAL;
80)display current time.
a)select to_char(sysdate,'hh:MM:ss') from dual.
81)Display the date three months Before the
current date.
a)select add_months(sysdate,3) from dual;
82)Display the common jobs from department
number 10 and 20.
a)select job from emp where deptno=10 and job
in(select job from emp
where deptno=20);
83)Display the jobs found in department 10 and
20 Eliminate duplicate
jobs.
a)select distinct(job) from emp where deptno=10
or deptno=20
or
select distinct(job) from emp where deptno
in(10,20);
84)Display the jobs which are unique to
department 10.
a)select distinct(job) from emp where deptno=10
85)Display the details of those who do not have
any person working
under them.
a)select e.ename from emp,emp e where
emp.mgr=e.empno group by e.ename
having count(*)=1;
86)Display the details of those employees who
are in sales department
and grade is 3.
a)
select * from emp where deptno=(select
deptno from dept where
dname='SALES')and
sal between(select losal from salgrade
where grade=3)and
(select hisal from salgrade where
grade=3);
87)Display those who are not managers and who
are managers any one.
i)display the managers names
a)select distinct(m.ename) from emp e,emp m
where m.empno=e.mgr;
ii)display the who are not managers
a)select ename from emp where ename not
in(select distinct(m.ename)
from emp e,emp m where m.empno=e.mgr);
88)Display those employee whose name contains
not less than 4
characters.
a)select ename from emp where
length(ename)>4;
89)Display those department whose name start
with "S" while the
location name ends with "K".
a)select dname from dept where dname like 'S%'
and loc like '%K';
90)Display those employees whose manager
name is JONES.
a)select p.ename from emp e,emp p where
e.empno=p.mgr and
e.ename='JONES';
91)Display those employees whose salary is more
than 3000 after giving
20% increment.
a)select ename,sal from emp where
(sal+sal*.2)>3000;
92)Display all employees while their dept names;
s)select ename,dname from emp,dept where
emp.deptno=dept.deptno
93)Display ename who are working in sales dept.
a)select ename from emp where deptno=(select
deptno from dept where
dname='SALES');
94)Display employee name,deptname,salary and
comm for those sal in
between 2000 to 5000 while location is chicago.
a)select ename,dname,sal,comm from emp,dept
where sal between 2000 and
5000 and loc='CHICAGO' and
emp.deptno=dept.deptno;
95)Display those employees whose salary greter
than his manager salary.
a)select p.ename from emp e,emp p where
e.empno=p.mgr and p.sal>e.sal
96)Display those employees who are working in
the same dept where his
manager is work.
a)select p.ename from emp e,emp p where
e.empno=p.mgr and
p.deptno=e.deptno;
97)Display those employees who are not working
under any manager.
a)select ename from emp where mgr is null
98)Display grade and employees name for the
dept no 10 or 30 but grade
is not 4 while joined the company before 31-dec-
82.
a)select ename,grade from emp,salgrade where
sal between losal and hisal and deptno in(10,30)
and grade<>4 and hiredate<'31-DEC-82';
99)Update the salary of each employee by 10%
increment who are not eligiblw for commission.
a)update emp set sal=sal+sal*10/100 where
comm is null;
100)SELECT those employee who joined the
company before 31-dec-82 while their dept
location is newyork or Chicago.
a)SELECT EMPNO,ENAME,HIREDATE,DNAME,LOC
FROM EMP,DEPT WHERE
(EMP.DEPTNO=DEPT.DEPTNO)AND
HIREDATE <'31-DEC-82' AND DEPT.LOC
IN('CHICAGO','NEW YORK');
101)DISPLAY EMPLOYEE
NAME,JOB,DEPARTMENT,LOCATION FOR ALL WHO
ARE
WORKING AS MANAGER?
A)select ename,JOB,DNAME,LOCATION from
emp,DEPT where mgr is not null;
102)dISPLAY THOSE EMPLOYEES WHOSE
MANAGER NAME IS JONES? --[AND ALSO
DISPLAY THEIR MANAGER NAME]?
A) SELECT P.ENAME FROM EMP E, EMP P WHERE
E.EMPNO=P.MGR AND
E.ENAME='JONES';
103)Display name and salary of ford if his salary
is equal to hisal of
his grade
a)select ename,sal,grade from emp,salgrade
where sal between losal and
hisal
and ename ='FORD' AND HISAL=SAL;
104)Display employee name,job,depart name
,manager name,his grade and
make out an under department wise?
a)SELECT
E.ENAME,E.JOB,DNAME,EMP.ENAME,GRADE FROM
EMP,EMP
E,SALGRADE,DEPT
WHERE EMP.SAL BETWEEN LOSAL AND HISAL
AND EMP.EMPNO=E.MGR AND
EMP.DEPTNO=DEPT.DEPTNO ORDER BY DNAME
105)List out all employees name,job,salary,grade
and depart name for every one in the company
except 'CLERK'.Sort on salary display the highest
salary?
a)SELECT ENAME,JOB,DNAME,SAL,GRADE FROM
EMP,SALGRADE,DEPT WHERE
SAL BETWEEN LOSAL AND HISAL AND
EMP.DEPTNO=DEPT.DEPTNO AND JOB NOT
IN('CLERK')ORDER BY SAL ASC;
106)Display the employee name,job and his
manager.Display also employee who are without
manager?
a)select e.ename,e.job,eMP.ename AS Manager
from emp,emp e where emp.empno(+)=e.mgr
107)Find out the top 5 earners of company?
a)SELECT DISTINCT SAL FROM EMP E WHERE
5>=(SELECT COUNT(DISTINCT SAL)
FROM EMP A WHERE A.SAL>=E.SAL)ORDER BY
SAL DESC;
108)Display name of those employee who are
getting the highest salary?
a)select ename from emp where sal=(select
max(sal) from emp);
109)Display those employee whose salary is
equal to average of maximum
and minimum?
a)select ename from emp where sal=(select
max(sal)+min(sal)/2 from
emp);
110)Select count of employee in each department
where count greater than 3?
a)select count(*) from emp group by deptno
having count(deptno)>3
111)Display dname where at least 3 are working
and display only
department name?
a)select distinct d.dname from dept d,emp e
where d.deptno=e.deptno and
3>any (select count(deptno) from emp group by
deptno)
112)Display name of those managers name
whose salary is more than average salary of his
company?
a)SELECT E.ENAME,EMP.ENAME FROM EMP,EMP E
WHERE EMP.EMPNO=E.MGR AND
E.SAL>(SELECT AVG(SAL) FROM EMP);
113)Display those managers name whose salary
is more than average salary of his employee?
a)SELECT DISTINCT EMP.ENAME FROM EMP,EMP E
WHERE E.SAL <(SELECT AVG(EMP.SAL) FROM
EMP
WHERE EMP.EMPNO=E.MGR GROUP BY
EMP.ENAME) AND EMP.EMPNO=E.MGR;
114)Display employee name,sal,comm and net
pay for those employee whose net pay is greter
than or equal to any other employee salary of
the company?
a)select ename,sal,comm,sal+nvl(comm,0) as
NetPay from emp where sal+nvl(comm,0) >any
(select sal from emp)
115)Display those employees whose salary is less
than his manager but more than salary of any
other manager?
a)
116)Display all employees names with total sal of
company with each
employee name?
a)SELECT ENAME,(SELECT SUM(SAL) FROM EMP)
FROM EMP;
117)Find out last 5(least)earners of the
company.?
a)SELECT DISTINCT SAL FROM EMP E WHERE
5>=(SELECT COUNT(DISTINCT SAL)
FROM EMP A WHERE A.SAL<=E.SAL)ORDER BY
SAL DESC;
118)Find out the number of employees whose
salary is greater than their manager salary?
a)SELECT E.ENAME FROM EMP ,EMP E WHERE
EMP.EMPNO=E.MGR AND
EMP.SAL<E.SAL;
119)Display those manager who are not working
under president but they are working under any
other manager?
a)
120)Display those department where no
employee working?
a)select dname from emp,dept where
emp.deptno not in(emp.deptno)
121)delete those records from emp table whose
deptno not available in dept table.
a)
122)Display those enames whose salary is out of
the grade available in salgrade table.
a)
123)Display employee name,sal,comm and whose
net pay is greater than
any other in the company?
a)
124)Display name of those employee who are
going to retrie 31-DEC-99.
if the maximum job period is 30 years?
a)
125)Display those employee whose salary is ODD
value?
a)select * from emp where sal<0;
126)Display those employee whose salary
contains alleast 3 digits?
a)select * from emp where length(sal)>=3;
127)Display those employee who joined in the
company in the month of
Dec?
a)select ename from emp where
to_char(hiredate,'MON')='DEC';
128)Display those employees whose name
contains "A"?
a)select ename from emp where
instr(ename,'A')>0;
or
select ename from emp where ename like('%A
%');
129)Display those employee whose deptno is
available in salary?
a)select emp.ename from emp, emp e where
emp.sal=e.deptno;
130)Display those employee whose first 2
characters from hiredate -last
2 characters of salary?
a)select ename,SUBSTR(hiredate,1,2)||ENAME||
substr(sal,-2,2) from emp
131)Display those employee whose 10% of salary
is equal to the year of
joining?
a)select ename from emp where
to_char(hiredate,'YY')=sal*0.1;
132)Display those employee who are working in
sales or research?
a)SELECT ENAME FROM EMP WHERE DEPTNO
IN(SELECT DEPTNO FROM DEPT WHERE
DNAME IN('SALES','RESEARCH'));
133)Display the grade of jones?
a)SELECT ENAME,GRADE FROM EMP,SALGRADE
WHERE SAL BETWEEN LOSAL AND
HISAL AND Ename='JONES';
134)Display those employees who joined the
company before 15 of the
month?
a)select ename from emp where
to_char(hiredate,'DD')<15;
135)Display those employee who has joined
before 15th of the month.
a)select ename from emp where
to_char(hiredate,'DD')<15;
136)Delete those records where no of employees
in a particular
department is less than 3.
a)delete from emp where deptno=(select deptno
from emp
group by deptno having count(deptno)<3);
137)Display the department name the no of
characters of which
is equal to no of employee in any other
department.
a)
138)Display the name of the department where
no employee working.
a)
139)Display those employees who are working as
manager.
a)
140)Count the no of employees who are working
as manager(using set
operations).
a)
141)Display the name of the dept those employee
who joined the company
on the same date?
a)
142)Display those employees whose grade is
equal to any number of sal
but not equal to first number of sal?
a)
143)Count the no of empployee working as
manager using set operaction?
a)
144)display the name of the employees who
joined the same date.
a)
145)Display the manager who is having maximum
number of employees working under him?
a)
146)list out employee name and salary increased
by 15% and expressed as whole number of
Dollars?
a)
147)Produce the output of the emp table "EMPLOYEE AND JOB" for ename and job? a)
148)List all employee with hiredate in the format
'june 4 1988'?
a)
149)Print lost of employees displaying "just
salary" if more than 1500
if exactly 1500 display 'On target' if less than
1500 Display below 1500?
A)select ename,sal,(case when sal>1500 then
'Below_target' when
sal=1500 then 'On_targer' when sal<1500 then
'less than target' else 'kkkkk' end )from emp
150)WHICH query to calcuate the length of time
any employee has been with the company?
151)Give 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
exprection 'Yes' if valid 'No' of not valid Use the
following values to test your soluction '$12/54(Not
clear).
a)
152)Employee hire on 15th of any month are paid
on the last Friday of that month. Those hired after
15th are paid the last Friday of the following
month.Print a list of employees.their hire date
and first pay date scort those whose salary
contains first digits of their deptno?
a)
select
ename,hiredate,last_day(next_day(hiredate,'FRID
AY')),deptno,
(case when to_char(hiredate,'DD')<=15 then
last_day(next_day(hiredate,'FRIDAY'))
when to_char(hiredate,'DD')>15 then
last_day(next_day(add_months(hiredate,1),'FRIDA
Y'))
end
)from emp order by substr(sal,0,2) ;
153)Display those manager who are getting less
than his employee
salary?
a)
154)Print the details of all the employees who are
Sub-ordinate to
BLAKE?
a)select emp.ename from emp, emp e where
emp.mgr=e.empno and
e.ename='BLAKE';
155)Display those who are working as manager
using CO-relate sub-query?
a)
156)Display those employee whose manager
name is jones and also with his manager name?
a)
157)Define variable representing the expression
used to calculate on
employee total Annual Remunatation?
a)
158)Use the variable in a statement which finds
all employees who can earn $30,000 a year or
more?
a)
159)Find out how many managers are there with
out listing them?
a)
160)Find out the average salary and average total
remuneration for each job type remember sales
man earn commission?
a)
161)Check whether all employees number are
indeed unique?
a)
162)List out the lowest paid employees working
for each manager exclude any groups where
minimum salary is less than Rs.1000 Sort the
output by salary?
a)
163)List ename,job,annual sal,deptno,dname and
grade who earn $36,000 a year or who are not
Clerks?
a)
164)Find out the job that was failedin the first half
of 1983 and same
job that was failed during the same period on
1984?
a)
165)Find out the employees who joined the
company before their manager?
a)
166)List out all the employees by name and
number along with their
manager's name and number also display %NG
who has no manager?
a)
167)Find out the employee who earned the
highest salary in each job
type Sort in desending salary order?
a)
168)Find out the employees who earned the
minimum salary for their job in Assending order?
a)
169)Find out the most resently hired employees
in each department Order by hiredate?
a)
170)Display ename,salary and deptno for each
employee who earn a salary greater than the
average for then department order by deptno?
a)
171)Display the department where there are no
employees?
a)
172)Display the department no with highest
annual remunaration bill as compensation?
a)
173)In which year did most people join the
company Display the year and number of
employees?
a)
174)Display the average salary figure for the
department?
a)select avg(SAL) from emp group by deptno
175)Write a query of display against the row of
the most recently hired employees Display ename
Hiredate and column max date showing;
a)
176)Display employee who can earn more than
lowest salary in department no 30?
a)
177)Find employees who can earn more than
every employee in deptno?
a)
178)Select dept name deptno and sum of salary?
a)
179)Find out average salary and average total
remainders for each job type?
a)
180)Find all departments which have more than 3
employees?
a)
181)Check whether employees number are
unique?
a)
182)List lowest paid employees working for each
manager exclude any
groups where the minimum salary less than 1000.
Sort the output by
salary?
a)
183)If the pay day is next friday after 15th and
30th of every
month.what is the next pay day from their hire
date for employee in emp table?
a)
184)If an employee is taken by you today in your
organisation.
And it is a policy in your company to have a
review after 9 months the
joined date (and of 1st of next month after 9
months )how many days from today your
employees has To wait for a review?
a)
185)Display employee name and his salary whose
salary is greater than highest average of
department number?
a)SELECT SAL FROM EMP WHERE SAL>(SELECT
MAX(AVG(SAL)) FROM EMP GROUP BY
DEPTNO);
186)Display the 10th record of emp table(without
using rowid)
a)
SELECT * FROM EMP WHERE
ROWNUM<11
MINUS
SELECT * FROM EMP WHERE
ROWNUM<10
187)Display the half of the ename's in upper case
and remaining
lowercase?
a)
SELECT
SUBSTR(LOWER(ENAME),1,3)||
SUBSTR(UPPER(ENAME),3,LENGTH(ENAME)) FROM
EMP;
188.
Display the 10th record of emp table
without using group by and rowid?
A)
SELECT * FROM EMP WHERE
ROWNUM<11
MINUS
SELECT * FROM EMP WHERE
ROWNUM<10
189.
Delete the 10th record of emp table.
A)
DELETE FROM EMP WHERE
EMPNO=(SELECT EMPNO FROM EMP WHERE
ROWNUM<11
MINUS
SELECT EMPNO FROM EMP WHERE
ROWNUM<10)
190.
Create a copy of emp table;
a)
create table new_table as select * from
emp where 1=2;
191.
Select ename if ename exists more than
once.
a)
select ename from emp e group by
ename having count(*)>1;
192.
Display all enames in reverse order?
(SMITH:HTIMS).
a)
SELECT REVERSE(ENAME)FROM EMP;
193.
Display those employee whose joining of
month and grade is equal.
A)
SELECT ENAME FROM EMP WHERE SAL
BETWEEN(SELECT LOSAL FROM SALGRADE
WHERE GRADE=TO_CHAR(HIREDATE,'MM')) AND
(SELECT HISAL FROM SALGRADE WHERE
GRADE=TO_CHAR(HIREDATE,'MM'));
194.
Display those employee whose joining
DATE is available in deptno.
A)
SELECT ENAME FROM EMP WHERE
TO_CHAR(HIREDATE,'DD')=DEPTNO
195.
Display those employees name as
follows
A ALLEN
B BLAKE
A)
SELECT SUBSTR(ENAME,1,1),ENAME
FROM EMP;
196.
List out the employees
ename,sal,PF(20% OF SAL) from emp;
A)
SELECT ENAME,SAL,SAL*.2 AS PF FROM
EMP;
197.
Display RSPS from emp without using
updating inserting.
A)
198.
Create table emp with only one column
empno;
A)
create table emp as select empno from
emp where 1=2;
199.
Add this column to emp table ename
vrachar2(20).
a)
alter table emp add(ename
varchar2(20));
200.
Oops I forgot give the primary key
constraint. Add in now.
a)
alter table emp add primary
key(empno);
201.
Now increase the length of ename
column to 30 characters.
a)
alter table emp modify(ename
varchar2(30));
202.
Add salary column to emp table.
alter table emp add(sal number(10));
203.
I want to give a validation saying that
salary cannot be greater
10,000(note give a name to this constraint)
a)
alter table emp add constraint chk_001
check(sal<=10000)
204.
For the time being I have decided that I
will not impose this
validation.
My boss has agreed to pay more than
10,000.
a)
again alter the table or drop constraint
with
alter table emp drop constraint
chk_001 (or)Disable the constraint by
using
a)
119)How many different courses are mentioned in
the studies table.
a)
120)Display the names of the programmers
whose names contain 2
concurrence of the.
a)
121)Display the names of programmers whose
names contaion upto 5
characters.
a)
122)How many female programmers knowing
cobol have more than 2 years
experience.
a)
123)What is the length of the shortest name in
programmer table.
a)
124)What is the average development cost of a
package developed in
cobol.
a)
125)Display the name,sex,dob(dd/mm/yy
format)for all programmers,
without using conversion function.
a)
126)Who are the programmers who were born on
the last day of the month.
a)
127)What is the amount paid in salaries of the
male programmers who don't know cobol.
a)
128)Display the Title______________________And
______________in descending order of differences.
a)
129)Display the names of the packages whose
names contains more than 1 word.
a)
130)Display the name,job,odj of those month of
birth & month of joining are the same.
a)
Thanks for delivering a good stuff ...
ReplyDeleteMicroservices Online Training
Microservices Training in Hyderabad