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 gro p by empno; !)Display the employee name and ann al salary for all employees" a)select ename,sal * 12 as ann alsalary from emp; #)Display the names of all the employees $ho are $or%ing in depart n mber 1&" a)select emame from emp $here deptno'1&; ()Display the names of all the employees $ho are $or%ing as cler%s and dra$ing a salary more than 3&&&" a)select ename from emp $here job')*+,-./) and sal03&&&; 1)Display the employee n mber and name $ho are earning comm" a)select empno,ename from emp $here comm is not n ll; 1&)Display the employee n mber and name $ho do not earn any comm" a)select empno,ename from emp $here comm is n ll; 11)display the names of employees $ho are $or%ing as cler%s,salesman or analyst and dra$ing a salary more than 3&&&" 2)select ename from emp $here job')*+,-.) 3435')/2+,/627) 3435')272+8/9) 27D /2+03&&&; 12)display the names of the employees $ho are $or%ing in the company for the past 5 years; a)select ename from emp $here to:char;sysdate,)8888))< to:char;hiredate,)8888))0'5; 13)Display the list of employcees $ho ha=e joined the company before 3&<4>7<1& or after 31<D,*<1&" a)select ename from emp $here hiredate ? )3&< 4>7<111&) or hiredate 0 )31<D,*<1&); 14)Display c rrent Date" a)select sysdate from d al; 15)Display the list of all sers in yo r database; se catalog table)" a)select sername from all: sers; 1!)Display the names of all tables from c rrent ser; a)select tname from tab; 1#)Display the name of the c rrent ser" a)sho$ ser 1()Display the names of employees $or%ing in depart n mber 1& or 2& or 4& or employees $or%ing as *+,-./, /2+,/627 or 272+8/9" a) /elect ename from emp $here deptno in;1&,2&,4&) or job in;)*+,-./),)/2+,/627),)272+8/9)); 11) Display the names of employees $hose name starts $ith alphabet /" a)select ename from emp $here ename li%e )/@); 2&) Display the ,mployee names for employees $hose name ends $ith 2lphabet /" a) /elect ename from emp $here ename li%e )@/); 21) Display the names of employees $hose names ha=e second alphabet 2 in their names" a) /elect ename from ,6A $here ename li%e ):2 @); 22) select the names of the employee $hose names is eBactly fi=e *haracters in length" a) select ename from emp $here length;ename)'5; 23) Display the names of the employee $ho are not $or%ing as 6272C,-/" a) /elect ename from emp $here job not in ;)6272C,-)); 24)Display the names of the employee $ho are not $or%ing as /2+,/627 3- *+,-. 3272+8/9" 2)select ename from emp $here job not in;)/2+,/627),)*+,-.),)272+8/9)); 25) Display all ro$s from ,6A table" 9he system sho ld $ait after e=ery /creen f ll of information" a) /et pa se on

3#)Display the names of the employee in descending order of salary" a)select ename from emp order by sal desc.sal from emp order by ename.sal) from emp. 5&)Display the =ario s jobs along $ith total n mber of employees in each job"9he o tp t sho ld contain only those jobs $ith more than three employees" .*)03.da. 4#)Display the =ario s jobs and total salary for each job a)select job.deptno.sal* 12)"9he name of the employee earning highest ann al salary sho ld apper first" a)select ename.sal) from emp.deptno.sal) from emp $here job')6272C.sal) from emp gro p by job.co nt.min. 41)Display name. 21)Display the minim m salary from emp table" a)select min. 2()Display the maBim m salary from emp table" a)select maB.da 1&@ of salary.sal) from emp $here deptno'2&./627).sal) from emp.sal.-.deptno)from emp gro p by deptno.total salary for each employee" 9he o tp t sho ld be in the order of total salary. 32)Display the maBim m salary being paid to depart n mber 2&" a)select maB.job)from emp gro p by job.s m.s m.6A.sal+salD1&&*15+salD1&&*1&<salD1&&*5 as total from emp.sal) from emp $here job')*+./627" a)select min.-. 44)Display the depart n mbers and total salary for each department" a)select deptno.-/" a)select a=g.).maB.sal) from emp $here job')/2+.salary. 35)Display the total salary dra$n by 272+8/9 $or%ing in depart n mber 4&" a)select s m. 3()Display the names of the employee in order of employee name" a)select ename from emp order by ename.hra 15@ of salary. 43)Display the =ario s jobs and total n mber of employees $ithin each job gro p" a)select job.salD1&&*15 as hra.co nt. 31)Display the maBim m salary being paid to *+. 41)Display the =ario s jobs along $ith total salary for each of the jobs $here total salary is greater than 4&&&&" a)select job." a)select maB.salD1&&*1& as da.pf.sal) from emp $here job')272+8/9) and deptno'4&.sal*12 from emp order by sal desc.2!) Display the total n mber of employee $or%ing in the company" a) /elect co nt .sal) from emp gro p by deptno.ename. 3!)Display the names of the employee in order of salary i"e the name of the employee earning lo$est salary sho ld salary appear first" a)select ename from emp order by sal.co nt.pf 5@ salary. 4()Display the depart n mbers $ith more than three employees in each dept" a)select deptno.total salary $ill be.sal) from emp gro p by job. 31)Display empno.*) from .s m.sal 4&)Display the name of the employee along $ith their ann al salary. 4!)Display the =ario s jobs and total salary for each job a)select job.sal) from emp gro p by job ha=ing s m. 33)Display the minim m salary being paid to any /2+.hra. 2#) Display the total salary beiging paid to all employees" a)select s m. 3&)Display the a=erage salary from emp table" a)select a=g.salD1&&*5 as pf.sal) from emp gro p by deptno. 34)Display the a=erage salary dra$n by 6272C.deptno.-).salary+hra+da)<pf" a)select ename. 45)Display the depart n mbers and maB salary for each department" a)select deptno.sal sort the o tp t first base on name and $ithin name by deptno and $ith in deptno by sal" a) select empno.sal) from emp.ename.deptno) from emp gro p by deptno ha=ing co nt. 42)Display depart n mbers and total n mber of employees $or%ing in each department" a)select deptno.sal)04&&&&.

ename)from emp.ename from emp $here $here job')*+. 52)Display the employee n mber and name for employee $or%ing as cler% and earning highest salary among cler%s" a)select empno./627)). !!)Display the length of 8o r name sing appropriate f nction" a)select length.+.)*omp ter 6aintenance *orporation).)).*9 62I.select deptno from dept $here dname')2**3>79E7C)) 51)Display the employee names $ho are $or%ing in *hicago" a)select ename from emp $here deptno'.select maB.-.+.select sal from emp $here deptno not in 1&)" !3)Display the names of the employees in >ppercase" a)select pper./.)).sal.2) from d al #&)Gind the Girst occ rance of character )a) from the follo$ing string i"e )*omp ter 6aintenance *orporation)" a)/. 435')6272C.ename) from emp.sal) from emp $here job')*+. !1)>ser approprate f nction and eBtract 3 characters starting from 2 characters from the follo$ing string )3racle)" i"e the o t p t sho ld be )ac)" a)select s bstr. 5!)Display the names of the employees $ho earn highest salary in their respecti=e departments" a)select ename./2+) G-36 .select sal from emp $here ename')437. 55)Display the names of employees $ho earn a salary more than that of 4ones or that of salary grether than that of scott" a)select ename.+.*9 435.1) G-36 D>2+ #1)-eplace e=ery occ rance of alphabhet 2 $ith 5 in the string 2llens.job)03 51)Display the name of the empployee $ho earns highest salary" a)select ename from emp $here sal'.sal) from emp $here job')*+.empno) from emp gro p by job ha=ing co nt.sal) from emp gro p by deptno)./))and sal0 .)a). 5#)Display the names of the employees $ho earn highest salaries in their respecti=e job gro ps" a)select ename.)name)) from d al !#)Display the length of all the employee names" a)select length./>6.sal) from emp).ename)from emp !5)Display the names of the employees in Aropercase" a)select initcap.select sal from emp $here ename')/*399)).) and sal'.-.sal) from emp $here job')/2+.)oracle).select maB.sal from emp $here job')/2+.co nt.6A C-3>A 58 435 F2HE7C />6.)2).sal) from emp gro p by job) 5()Display the employee names $ho are $or%ing in acco nting department" a)select ename from emp $here deptno'. 53)Display the names of salesman $ho earns a salary more than the highest salary of any cler%" a)select ename.job from emp $here sal in.sal from emp $here sal0 . 54)Display the names of cler%s $ho earn a salary more than the lo$est salary of any salesman" 2)select ename from emp $here job')*+. se translate f nction) a)select translate.)5)) from d al #2)Display the informaction from emp table"Jhere job manager is fo nd .-./2+) G-36 .select maB.select maB.)2llens).6A JF.a)select job.-.*9 E7/9-. !1)Display the names of employees from department n mber 1& $ith salary grether than that of any employee $or%ing in other department" a)select ename from emp $here deptno'1& and sal0any.select min.-)).deptno from emp $here sal in.sal.select deptno from dept $here +3*')*FE*2C3)) !&)Display the 4ob gro ps ha=ing total salary greater than the maBim m salary for managers" a)/.) and sal0.select sal from emp $here deptno not in 1&)" !2)Display the names of the employees from department n mber 1& $ith salary greater than that of all employee $or%ing in other departments" a)select ename from emp $here deptno'1& and sal0all. !()select name of the employee concatenate $ith employee n mber" select enameKKempno from emp./627) and sal0.3.-./2+)0.ename)from emp !4)Display the names of the employees in +o$ecase" a)select lo$er.select maB.

1&)Display those employees $hose manager name is 437.D29. #1)Gind the date for nearest sat rday after c rrent date" a)/.D 9F.)./8/D29.select distinct. (1)Display those department $hose name start $ith N/N $hile the location name ends $ith N.3&./))and sal bet$een. *36A278 37 )KKto:char.)3A-29E37/)) from emp.)6272C.select hisal from salgrade $here grade'3).6A./).select losal from salgrade $here grade'3)and .-).2&)..435.dept $here emp"deptno'dept"deptno 13)Display ename $ho are $or%ing in sales dept" a)select ename from emp $here deptno'.)53//)) G-36 .job) from emp $here deptno in.)ddth 6onth day year)) from d al ##)Display the follo$ing o tp t for each ro$ from emp table" #()scott has joined the company on $ednesday 13th 2 g st ninten nintey" a)select . ii)display the $ho are not managers a)select ename from emp $here ename not in.)2**3>79E7C).)/29>-D28))G-36 D>2+.job) from emp $here deptno'1& or deptno'2& or select distinct.1&.sysdate)<to:date.emp e $here emp"mgr'e"empno gro p by e"ename ha=ing co nt.)-. (&)display c rrent time" a)select to:char. 12)Display all employees $hile their dept names. (4)Display the jobs $hich are niM e to department 1&" a)select distinct.emp m $here m"empno'e"mgr)./).6A.)day ddth 6onth year)) from .m"ename) from emp e.deptno from emp table"Enstead of display department n mbers display the related department name.m"ename) from emp e.select job from emp $here deptno'2&).ename.sysdate.2 &.sysdate.emp p $here e"empno'p"mgr and e"ename')437.+.)1&<sep< ##))from d al #5)Display yo r age in months" a)select months:bet$een.sal from emp $here . (2)Display the common jobs from department n mber 1& and 2&" a)select job from emp $here deptno'1& and job in. (#)Display those $ho are not managers and $ho are managers any one" i)display the managers names a)select distinct.I9:D28.)hhL66Lss)) from d al" (1)Display the date three months 5efore the c rrent date" a)select add:months.select deptno from dept $here dname')/2+..*)'1.)1&<sep<##)) from d al #!)Display the c rrent date as 15th 2 gest Griday 7ineteen 7inety /a=en" a)select to:char.726.>se replace f nction)" a)select replace.3) from d al.deptno. s)select ename. #3)Display empno.sysdate.ename)04.job) from emp $here deptno'1& (5)Display the details of those $ho do not ha=e any person $or%ing nder them" a)select e"ename from emp. (3)Display the jobs fo nd in department 1& and 2& .select deptno from dept $here dname')/2+.2-*F).sal+sal*"2)03&&&./)).KK) F2/ 43E7./" a)select p"ename from emp e. #4)Display yo r age in days" a)select to:date.)/2+.ename.dname from emp. (()Display those employee $hose name contains not less than 4 characters" a)select ename from emp $here length.sysdate.1&.>se decode f nction)" a)select empno.decode.liminate d plicate jobs" a)select distinct. . 11)Display those employees $hose salary is more than 3&&& after gi=ing 2&@ increment" a)select ename.*9 7.emp m $here m"empno'e"mgr./.FE-.it sho ld be displayed as boos.4&. (!)Display the details of those employees $ho are in sales department and grade is 3" a) select * from emp $here deptno'.N" a)select dname from dept $here dname li%e )/@) and loc li%e )@.

6A"D.27D .salgrade $here sal bet$een losal and hisal and deptno in. G-36 .A9"+3* E7.7 +3/2+ 27D FE/2+ 27D ..-.*9 *3>79. 1&&)/.emp e $here d"deptno'e"deptno and 30any ..726.6A.+.*) from emp gro p by deptno ha=ing co nt.+.A973'D.D. 1&5)+ist o t all employees name.58 /2+ 2/*.58 D726.A2-96."6C.6A 2 JF. 726..salary and comm for those sal in bet$een 2&&& to 5&&& $hile location is chicago" a)select ename. .salary.".A973 27D 435 739 E7.select co nt.6A"D.9J. . /2+ 5..435.-.C-2D.sal) from emp).D726.sal)+min.726.A973'D.+3*29E37 G3.*<(2)..6A .6A.job.+.sal./.)). J3-.)7.deptname.emp p $here e"empno'p"mgr and p"sal0e"sal 1!)Display those employees $ho are $or%ing in the same dept $here his manager is $or%" a)select p"ename from emp e.6A".salgrade $here sal bet$een losal and hisal and ename ')G3-D) 27D FE/2+'/2+.6A73."435.grade from emp..6A .job.. 50'. JF.*9 A".../ JF3/.C-2D.D. ?)31<D.A973'D....deptno)03 111)Display dname $here at least 3 are $or%ing and display only department nameO a)select distinct d"dname from dept d.. 1&2)dE/A+28 9F3/.A9"D.726.726.J 83-..e6A"ename 2/ 6anager from emp.+3* G-36 ..e"job.A973)27D FE-.79.6A"/2+ 5.A9 JF.6A .6A"D. 15)Display those employees $hose salary greter than his manager salary" a)select p"ename from emp e.depart name .)*+.select maB..comm from emp.A9 JF..+. 1#)Display those employees $ho are not $or%ing nder any manager" a)select ename from emp $here mgr is n ll 1()Display grade and employees name for the dept no 1& or 3& b t grade is not 4 $hile joined the company before 31<dec< (2" a)select ename.726.*<(2) 27D D. 1&()Display name of those employee $ho are getting the highest salaryO a)select ename from emp $here sal'.*9 .+)'e"mgr 1&#)Gind o t the top 5 earners of companyO a)/.435.A9"D.6A+38.".D726.. 2"/2+0'.D726.6A.-.2++ JF3 2-.6A".+3*29E37 from emp.A9 $here mgr is not n ll. 1&!)Display the employee name.435.dept $here sal bet$een 2&&& and 5&&& and loc')*FE*2C3) and emp"deptno'dept"deptno....')437.726.7 +3/2+ 27D FE/2+ 27D .deptno) from emp gro p by deptno) .".grade and depart name for e=ery one in the company eBcept )*+./). 1&1)DE/A+28 . .D29.6A A JF.A9 JF.A9"D. 11)>pdate the salary of each employee by 1&@ increment $ho are not eligibl$ for commission" a) pdate emp set sal'sal+sal*1&D1&& $here comm is n ll.-O 2)select ename.grade from emp.select maB.D29./2+./2+C-2D.D.D726. G-36 .)"/ort on salary display the highest salaryO a)/.)*FE*2C3).emp p $here e"empno'p"mgr and p"deptno'e"deptno.manager name.E7C 2/ 6272C.6A73'A"6C. 1&4)Display employee name.*9 DE/9E7*9 /2+ G-36 ..*9 .3&) and grade?04 and hiredate?)31<D.*9 .58 /2+ D.6A+38."/2+)3-D.14)Display employee name.726.D..+.-.FE-.27D .+.9J. 11&)/elect co nt of employee in each department $here co nt greater than 3O a)select co nt.-. 1&3)Display name and salary of ford if his salary is eM al to hisal of his grade a)select ename.job and his manager"Display also employee $ho are $itho t managerO a)select e"ename.emp e $here emp"empno..D..1&.))3-D.QO 2) /.E.his grade and ma%e o t an nder department $iseO a)/.*9 those employee $ho joined the company before 31<dec<(2 $hile their dept location is ne$yor% or *hicago" a)/..-. 1&1)Display those employee $hose salary is eM al to a=erage of maBim m and minim mO a)select ename from emp $here sal'./2+C-2D. . 6272C.-.sal.+.A973 3-D.sal)D2 from emp). E/ 437.6272C. ./*./O <<P27D 2+/3 DE/A+28 9F.-.6A73'..DE/9E7*9 /2+) G-36 ..726.dname. G-36 .

6A"/2+?.name')437. E7.-.&) 0any .-.6A. G-36 .*<11" if the maBim m job period is 3& yearsO a) 125)Display those employee $hose salary is 3DD =al eO a)select * from emp $here sal?&.726. G-36 . 114)Display employee name.6A .+. 2"/2+?'.sal.726.*9 .A9 JF..+.27D .6A 2 JF. /2+ 5.+. JF.6A73'.6A".6A .*9 *3>79./.hiredate.A973 E7.+.*9 DE/9E7*9 .726."6C. 12()Display those employees $hose name contains N2NO a)select ename from emp $here instr.".+.C-3>A 58 .6A". emp e $here emp"sal'e"deptno. or select ename from emp $here ename li%e.27D .6A. .6A".least)earners of the company"O a)/.sal. 11#)Gind o t last 5.6A .dept $here emp"deptno not in. 12!)Display those employee $hose salary contains alleast 3 digitsO a)select * from emp $here length. D./).A973 G-36 D.2-*F))).6A.6A JF.726.."/2+0. JF.comm. 13&)Display those employee $hose first 2 characters from hiredate <last 2 characters of salaryO a)select ename..select sal from emp) 115)Display those employees $hose salary is less than his manager b t more than salary of any other managerO a) 11!)Display all employees names $ith total sal of company $ith each employee nameO a)/.*9 .."/2+)3-D.sal./2+) G-36 .+.-.6A73'."/2+ ?.*9 .)88))'sal*&"1.comm.)/2+.C-2D."6C-.726.6A . 111)Display those manager $ho are not $or%ing nder president b t they are $or%ing nder any other managerO a) 12&)Display those department $here no employee $or%ingO a)select dname from emp.726.726.) 27D .+. .-. 12#)Display those employee $ho joined in the company in the month of DecO a)select ename from emp $here to:char.-.+."./.ename.)2))0&.hiredate. 134)Display those employees $ho joined the company before 15 of the monthO a)select ename from emp $here to:char.sal+n=l. JF./>5/9-.comm and $hose net pay is greater than any other in the companyO a) 124)Display name of those employee $ho are going to retrie 31<D.. 50'.emp"deptno) 121)delete those records from emp table $hose deptno not a=ailable in dept table" a) 122)Display those enames $hose salary is o t of the grade a=ailable in salgrade table" a) 123)Display employee name. 113)Display those managers name $hose salary is more than a=erage salary of his employeeO a)/.&) as 7etAay from emp $here sal+n=l.58 /2+ D.comm and net pay for those employee $hose net pay is greter than or eM al to any other employee salary of the companyO a)select ename.2) from emp 131)Display those employee $hose 1&@ of salary is eM al to the year of joiningO a)select ename from emp $here to:char../2+) G-36 . 121)Display those employee $hose deptno is a=ailable in salaryO a)select emp"ename from emp.*9 />6. D726.726./*. 132)Display those employee $ho are $or%ing in sales or researchO a)/.6A JF.*9 2HC./.)637))')D./. .hiredate. G-36 .*9 .-."6C.2)KK.6A)./.6A . .-."6C..."/2+.DE/9E7*9 /2+) G-36 .+./2+C-2D.*9 D.726..-.1.)DD))?15. JF.*9 2HC.sal.+.*9 .6A"/2+) G-36 .9J.*).6A".6A".hiredate.6A".6A) G-36 . JF./.112)Display name of those managers name $hose salary is more than a=erage salary of his companyO a)/.)@2 @)). 11()Gind o t the n mber of employees $hose salary is greater than their manager salaryO a)/.7 +3/2+ 27D FE/2+ 27D ./). 133)Display the grade of jonesO a)/..)-.KK s bstr. G-36 . G-36 .+..comm.*9 DE/9E7*9 /2+ G-36 .6A73'.+.-. .6A.6A".6A73'.<2.sal)0'3.

.hiredate. sing set operations)" a) 141)Display the name of the dept those employee $ho joined the company on the same dateO a) 142)Display those employees $hose grade is eM al to any n mber of sal b t not eM al to first n mber of salO a) 143)*o nt the no of empployee $or%ing as manager sing set operactionO a) 144)display the name of the employees $ho joined the same date" a) 145)Display the manager $ho is ha=ing maBim m n mber of employees $or%ing nder himO a) 14!)list o t employee name and salary increased by 15@ and eBpressed as $hole n mber of DollarsO a) 14#)Arod ce the o tp t of the emp table N.select deptno from emp gro p by deptno ha=ing co nt.hiredate.)G-ED2 8))) end )from emp order by s bstr. 155)Display those $ho are $or%ing as manager sing *3<relate s b<M eryO a) 15!)Display those employee $hose manager name is jones and also $ith his manager nameO . emp e $here emp"mgr'e"empno and e"ename')5+2.sal.neBt:day. case $hen to:char.hiredate.neBt:day..135)Display those employee $ho has joined before 15th of the month" a)select ename from emp $here to:char.)..case $hen sal015&& then )5elo$:target) $hen sal'15&& then )3n:targer) $hen sal?15&& then )less than target) else )%%%%%) end )from emp 15&)JFE*F M ery to calc ate the length of time any employee has been $ith the companyO 151)Ci=e a string of the format )nnDnn) Herify that the first and last 2 characters are n mbers"2nd that the middle character is )D) Arint the eBprection )8es) if =alid )7o) of not =alid >se the follo$ing =al es to test yo r sol ction )R12D54.O a)select emp"ename from emp. .2) .hiredate.)G-ED28))) $hen to:char.&.last:day.mployee hire on 15th of any month are paid on the last Griday of that month" 9hose hired after 15th are paid the last Griday of the follo$ing month"Arint a list of employees"their hire date and first pay date scort those $hose salary contains first digits of their deptnoO a) select ename.hiredate.)DD))?15.deptno.. 13!)Delete those records $here no of employees in a partic lar department is less than 3" a)delete from emp $here deptno'. 153)Display those manager $ho are getting less than his employee salaryO a) 154)Arint the details of all the employees $ho are / b<ordinate to 5+2.)G-ED 28))).1).)DD))015 then last:day. 27D 435N for ename and jobO a) 14()+ist all employee $ith hiredate in the format )j ne 4 11(()O a) 141)Arint lost of employees displaying Nj st salaryN if more than 15&& if eBactly 15&& display )3n target) if less than 15&& Display belo$ 15&&O 2)select ename.6A+38. 13#)Display the department name the no of characters of $hich is eM al to no of employee in any other department" a) 13()Display the name of the department $here no employee $or%ing" a) 131)Display those employees $ho are $or%ing as manager" a) 14&)*o nt the no of employees $ho are $or%ing as manager.deptno)?3).add:months.7ot clear)" a) 152).)DD))?'15 then last:day.hiredate.sal.neBt:day.hiredate.

a) 1#!)Display employee $ho can earn more than lo$est salary in department no 3&O a) 1##)Gind employees $ho can earn more than e=ery employee in deptnoO a) 1#()/elect dept name deptno and s m of salaryO a) 1#1)Gind o t a=erage salary and a=erage total remainders for each job typeO a) 1(&)Gind all departments $hich ha=e more than 3 employeesO a) 1(1)*hec% $hether employees n mber are niM eO a) 1(2)+ist lo$est paid employees $or%ing for each manager eBcl de any gro ps $here the minim m salary less than 1&&&" /ort the o tp t by salaryO a) 1(3)Ef the pay day is neBt friday after 15th and 3&th of e=ery month"$hat is the neBt pay day from their hire date for employee in emp tableO a) ./2+) from emp gro p by deptno 1#5)Jrite a M ery of display against the ro$ of the most recently hired employees Display ename Firedate and col mn maB date sho$ing.&&& a year or $ho are not *ler%sO a) 1!4)Gind o t the job that $as failedin the first half of 11(3 and same job that $as failed d ring the same period on 11(4O a) 1!5)Gind o t the employees $ho joined the company before their managerO a) 1!!)+ist o t all the employees by name and n mber along $ith their manager)s name and n mber also display @7C $ho has no managerO a) 1!#)Gind o t the employee $ho earned the highest salary in each job type /ort in desending salary orderO a) 1!()Gind o t the employees $ho earned the minim m salary for their job in 2ssending orderO a) 1!1)Gind o t the most resently hired employees in each department 3rder by hiredateO a) 1#&)Display ename.deptno.a) 15#)Define =ariable representing the eBpression sed to calc late on employee total 2nn al -em natationO a) 15()>se the =ariable in a statement $hich finds all employees $ho can earn R3&.&&& a year or moreO a) 151)Gind o t ho$ many managers are there $ith o t listing themO a) 1!&)Gind o t the a=erage salary and a=erage total rem neration for each job type remember sales man earn commissionO a) 1!1)*hec% $hether all employees n mber are indeed niM eO a) 1!2)+ist o t the lo$est paid employees $or%ing for each manager eBcl de any gro ps $here minim m salary is less than -s"1&&& /ort the o tp t by salaryO a) 1!3)+ist ename.salary and deptno for each employee $ho earn a salary greater than the a=erage for then department order by deptnoO a) 1#1)Display the department $here there are no employeesO a) 1#2)Display the department no $ith highest ann al rem naration bill as compensationO a) 1#3)En $hich year did most people join the company Display the year and n mber of employeesO a) 1#4)Display the a=erage salary fig re for the departmentO a)select a=g.ann al sal.job.dname and grade $ho earn R3!.

/2+*"2 2/ AG G-36 . 11#" Display -/A/ from emp $itho t sing pdating inserting" 2) 11(" *reate table emp $ith only one col mn empno.)66))) 27D .A973).*9 .*9 * G-36 .*9 62I.*9 * G-36 . 11!" +ist o t the employees ename.sal?'1&&&&) 2&4" Gor the time being E ha=e decided that E $ill not impose this =alidation" 6y boss has agreed to pay more than 1&. 1((" Display the 1&th record of emp table $itho t sing gro p by and ro$idO 2) /.and of 1st of neBt month after 1 months )ho$ many days from today yo r employees has 9o $ait for a re=ie$O a) 1(5)Display employee name and his salary $hose salary is greater than highest a=erage of department n mberO a)/.-/.*9 .-.726.1.+..6A. G-36 .6A JF.*9 * G-36 .6A JF.+. -3J7>6?1& 1(#)Display the half of the ename)s in pper case and remaining lo$ercaseO a) /.6A.2HC.2&)" a) alter table emp add.. 2&2" 2dd salary col mn to emp table" alter table emp add.-.726.'93:*F2-.-.-. 2&3" E $ant to gi=e a =alidation saying that salary cannot be greater 1&. 2) /.D29.D29. 1(!)Display the 1&th record of emp table.6A JF.6A JF.6A.3)KK />5/9-.+./6E9FLF9E6/)" a) /.+3J.ename =archar2. JF.)G-36 .H. 2&&" 3ops E forgot gi=e the primary %ey constraint" 2dd in no$" a) alter table emp add primary %ey.1(4)Ef an employee is ta%en by yo today in yo r organisation" 2nd it is a policy in yo r company to ha=e a re=ie$ after 1 months the joined date .*9 />5/9-.+.*9 -.+.*9 /2+ G-36 .7C9F..*9 FE/2+ G-36 /2+C-2D. 93:*F2-.726.. 2) /.2&@ 3G /2+) from emp.&&&.FE-.-.1).726. G-36 .. G-36 .6A73 G-36 .>AA.FE-. /2+0.-.). is a=ailable in deptno" 2) /..*9 />5/9-./.)DD))'D.6A JF.+.-.*)01.1&)).AG. -3J7>6?11 6E7>/ /..+.'93:*F2-..3.+. 114" Display those employee $hose joining D29.-.-. -3J7>6?11 6E7>/ /. 112" Display all enames in re=erse orderO .7.7 5 5+2.+.+.726.)66))). .*9 * G-36 . C-2D.sal n mber.1.+. -3J7>6?1& 1(1" Delete the 1&th record of emp table" 2) D.6A JF.D29.).*9 .726. 2) create table emp as select empno from emp $here 1'2.-.)) G-36 . JF.&&&" a) again alter the table or drop constraint $ith alter table emp drop constraint ch%:&&1 .-.-.6A JF..9.6A JF.+.A973 115" follo$s Display those employees name as 2 2++.*9 .726.6A JF.-. -3J7>6?1&) 11&" *reate a copy of emp table. G-36 .6A73'.-./.9J.6A.ename =archar2.+.+.6A JF. 111" /elect ename if ename eBists more than once" a) select ename from emp e gro p by ename ha=ing co nt./.empno).note gi=e a name to this constraint) a) alter table emp add constraint ch%:&&1 chec%.*9 +3/2+ G-36 /2+C-2D.. /2+ 5. 111" 2dd this col mn to emp table ename =rachar2.+. 2&1" 7o$ increase the length of ename col mn to 3& characters" a) alter table emp modify.726./2+)) G-36 .3&)).*9 .FE-.+.6A73 G-36 ../2+.2&))..6A C-3>A 58 D.$itho t sing ro$id) a) /.sal. a) create table ne$:table as select * from emp $here 1'2.+./.+.. -3J7>6?11 6E7>/ /.or)Disable the constraint by sing .726. C-2D. 113" Display those employee $hose joining of month and grade is eM al" 2) /..

2&!" table./ .6A.ename) from emp.alter table emp modify constraint ch%:&&1 disable.sal) from emp.dept $here emp"deptno'dept"deptno 21#" Display employee n mber. a) alter table emp add constraint dept:&&1 foreign %ey. 21(" Display ename.6A73) 2&(" a) 2dd deptno col mn to yo r emp table.loc. se create table as). 2&1" 9his deptno col mn sho ld be related to deptno col mn of dept table.emp p $here e"empno'p"mgr.e"ename from emp e.5)).sysdate< hiredate)D3!502.dname from emp.select min.. 212" *reate table called as ne$emp" 9his table sho ld contain only empno. 213" Delete the ro$s of employees $ho are $or%ing in the company for more than 2 years" a) delete from emp $here . a) 2dd col mn called as mgr to yo r emp alter table emp add.s m..dept $here emp"deptno'dept"deptno.dname" a) create table ne$emp as select empno. a)delete from emp $here ro$id not in.deptno) reference dept.G.s m.6C-) -.&&&" so re=o%e that salary constraint" a) alter table emp modify constraint ch%:&&1 enable. 22&" Display the department name and total n mber of employees in each department" a) select dname. a) create table ne$emp as select * from emp. 2&5" 6y boss has changed his mind" 7o$ he doesn)t $ant to pay more than 1&.EC7 .name and location of the department in $hich he is $or%ing" a) select empno. 214" Aro=ide a commission.dept $here 1'2. alter table emp add.+) 211" Display employee name and his manager name" a) select p"ename.7*.6A 2DD *37/9-2E79 6C-:D.dname from emp.dept $here emp"deptno'dept"deptno gro p by dname.mgr n mber.ename.dept $here emp"deptno'dept"deptno.-.. and gi=e commit" *ome bac% to second system and gi=e the follo$ing command /elect * from emp" 2nsL*hanges Jill be affect in second system" T)Jrite a T ery 9o Delete 9he -epeted -o$s from emp table.co nt.deptno) Pdeptno sho ld be primary %eyQ 21&" Ci=e the command to add the constraint" 2) alter table ?table:name) add constraint ?constraint:name0 ?constraint type0 211" *reate table called as ne$emp" >sing single command create this table as $ell as get data into this table.ename. a) pdate emp set comm'sal*"1 $here comm is not n ll.dname from emp. 222" Display itemname and total sales amo nt for each item" a) select itemname.A9 G3-.925+. se o ter join)" a) select ename.8.deptno n mber.5)).1&@ *omm 3f /al) to employees $ho are not earning any commission" a) select sal*&"1 from emp $here comm is n ll 215" Ef any employee has commission his commission sho ld be incremented by 1&@ of his salary" . 223" Ci=e the follo$ing commandsL Delete from emp $here job )cler%) Enset into emp $itho t gi=ing any f rther commands mo=e to another client system and log into the same ser gi=e the follo$ing command select * from emp" 1"2re the abo=e changes reflected in this serO.amo nt) from item gro p by itemname.ename.ro$id)from emp gro p by ename) 2&#" 3hS 9his col mn sho ld be related to empno" Ci=e a command to add this constraint" 2) 2+9.yes) 2"Coto yo r first system. 221" Display the department name along $ith total salary in each department" a) select dname. 21!" Display employee name and department name for each employee" a) select empno.dname e=en if there are no employees $or%ing in a partic lar department. .dept $here emp"deptno'dept"deptno gro p by dname.dname from emp.

ccost) from st dies gro p by inst./ 52/.)88)).D Do$nload Gile K /a=e to my 8ahooS 5riefcase Q Plain Text Attachment P T>./ 925+. /3G9J2-.co nt.co nt. 1!)Display the sales cost of the pac%ages de=eloped by each programmer lang age$ise" a) 1#)Display the lang age name $ith a=erage de=elopment cost and selling cost" a) 1()Display the name of each programmer $ith the costiest pac%age cheapest pac%age de=eloped by himDher" a) 11)Display each instit te name $ith n mber of co rses and a=erage cost per co rse" a)select inst. 2)Display the n mber of pac%ages de=eloped by each person" a)select co nt.)*). U /9>DE.-E. 5)Display the n mber of people born in each year" a)select to:char.co rse) from st dies gro p by co rse.dob) from programer gro p by to:char. 21)Display the names of male programmers" a)select pname from programer $here seB')6).salary) from programer gro p by salary.co nt.)*pp)) gro p by de=:in.title) from soft$are gro p by de=:in.)88)).co rse).title from soft$are.-.s m.pname) from soft$are gro p by pname.scost+dcost from soft$are. 3)Display the n mber of male and female programmers" a)select seB.dob) from programer gro p by to:char. 14)Display the sales =al e of the pac%ages de=eloped by each programmer" a) 15)Display the n mber of pac%ages sold by each programmer" a)select co nt. 24)Display the n mber of pac%ages in each lang age for $hich de=elopment cost is greater than 1&&&" .dcost) from soft$are gro p by de=:in.co nt.co nt. 12)Display the total selling cost of the pac%ages de=eloped in each lang age" a) 13)Display the cost of pac%age de=eloped by each programmer" a)select pname.dob.co nt. 1)Display the n meber of people in each instit te" a)select co nt.sold) from soft$are gro p by de=:in. 22)Display the programmers name and pac%ages de=eloped by himDher" a)select pname. ()Display the n mber of people in each salary gro p" a)select salary.inst) from st dies gro p by inst.dob.maB.co nt.)66)).dcost).inst)from st dies gro p by inst. 2&)Display each instit te name $ith n mber of st dents" a)select inst.prof1) from programer gro p by prof1. 23)Display the n mber of pac%ages in each lang age.dob.maB. 11)Display the 9otal de=elopment cost of the pac%ages de=eloped in each lang age" a)select de=:in. 4)Display the costiest pac%age and the highest selling pac%age de=eloped in each lang age" a)select de=:in. eBcept c U c++" a)select co nt.)66)). #)Display the lang age<$ise co nt of prof1" a)select prof1. 1&)Display the n mber of people $ho st died in each gro p" a)select co nt.dob.a=g. !)Display the n mber of people joined in each month" a)select to:char.title) from soft$are gro p by pname.seB) from programer gro p by seB.title) from soft$are $here de=:in not in./ :::::::::::::::::::::::::::::::::::::::::::::::::: :::: 1)Display the n mber of pac%ages de=eloped in each" a)select co nt.D 37 A-3C-266.

3&)Display the names of the highest paid programmer for each lang age prof1" a)select pname from programer $here salary in./F).-. 3#)Display the names and ages of all the programmers" a)select pname.-.salary from programer $here salary'.)*).')-26.*9 62I.+. 35)Jhich female programmer earining more than 3&&& does not %no$ c. 25)Display the a=erage difference bet$een /cost and Dcost for each lnag age" a)select a=g. 3!)Gind o t the a=erage selling cost for pac%ages de=eloped in pascal" a)select a=g.*9 /*3/9 G-36 /3G9J2-.select maB.')ACD*2).*3>-/.*9 />6.)637))')427). /*3/9'.+.)Dbase)) .-.*9 *3>79. 32)Jho is the most eBperienced programmer in A2/*2+" a)select maB.doj)from programer $here prof1')Aascal) or prof2')Aascal).dob.salary) from programer $here salary02&&&.+.-.min.a=g.oracle or dbase" a)select pname from programer $here seB')G) and salary03&&& and prof1 not in.dcost and amo nt to be reco=ered for each programmer by those $hose dcost has not yet been reco=ered" a) 2()Jho is the highest paid c programmer" a)select pname.*9 6E7.lo$est and a=erage salaries for those earning more than 2&&&" a)select maB./.sysdate<dob)D3!5 as age from programer" 3()Display the names of those $ho ha=e done the D2A co rse" a)select pname from st dies $here co rse')D2A).*9 * G-36 /3G9J2-.) G-36 /9>DE..doj)from programer. 33)Jhich lang age is %no$n by only one programmer" a) 34)Jho is the yo ngest programmer %no$ing dbase" a)select pname from programer $here dob'.) G-36 /9>DE. E7/9')/25F2-E). 43)Display the details of the soft$are de=eloped by -26.salary).)*). JF./3+D*/*3/9) G-36 /3G9J2-.salary) from programer $here prof1')*) or prof2')*)). 4!)Gind o t the n mber of copies.)3racle). JF.a)select co nt.salary) from programer $here seB')G) and prof1')*obol) or prof2')*obol)).*3>-/.**3/9) G-36 /9>DE.dob from programer $here to:char..+.-. 31)Display the name and date of birth of all programmers born in jan ary" a)select pname.scost<dcost) from soft$are. 42)Fo$ m ch re=en e has been earned thro gh the sale of pac%ages de=eloped" a)/./.*9 *3>79. 2#)Display the total scost.+.+. /3+D02&&&.select maB.salary from programer $here salary'./*3/9) G-36 . *3>-/.select maB.)3racle). 2!)Display highest. JF./F" a)/.)*pp).title) from soft$are $here dcost01&&& gro p by de=:in.c++. 41)Fo$ many programmer ha=e done the ACD*2 co rse" a)/. $hich sho ld be sold in order to reco=ered the de=elopment cost of each pac%ages" a) 4#)Display the details of pac%ages for $hich de=elopment cost has been reco=ered" a) 4()Jhat is the price of the costiest soft$are de=eloped in 5asic" a)/. 45)Display the details oG pac%ages $hose sales crossed the 2&&& mar%" a)/.*9 * G-36 /3G9J2-. A726.)Dbase)) and prof2 not in.+.scost * sold) from soft$are $here de=:in')Aascal).dob) from programer $here prof1')Dbase) or prof2')Dbase))./ JF.)*pp).+. 21)Jho is the highest paid female cobol programmer" a)select pname.salary).select maB.salary) from programer gro p by prof1) 31)Jho is the least eBperienced programmer" a)select min./ JF. 4&)Display the lo$est co rse fee" a)/. 44)Fo$ many programmers st died at /25F2-E" a)/.

5&)Jhat is the a=erage co rsefee" a)/. #&)Jhich pac%age has the highest de=elopment cost" a)select title from soft$are $here dcost'. #1)Jhich pac%age has lo$est selling price" a)select title from soft$are $here dcost'.)Aascal))and prof2 not in.-.sold)from soft$are)..H:E7')D52/.)*lipper).JF. 41)Fo$ many pac%ages are de=eloped in Dbase" a)/.-.)Aascal)) and prof2 not in. !3)Jhich instit te has maBim m n mber of st dents" a) !4)Jhich co rse has been done by the maBim m n mber of st dents" a) !5)Display the name of the instit e and co rse $hich has belo$ a=erage co rse fee" a)select inst.H:E7')52/E*)).dob.pname) G-36 A-3C-26..select min./ JF.JF.-./ JF.salary) from programer.) G-36 /9>DE.+.ccost) from st dies). 5#)Jho are the programmers $ho celebrate their birthdays d ring the c rrent month" a)select pname from programer $here to:char.*9 2HC.sysdate.)mm))'to:char.)*). 5()Fo$ many female programmers are there" a)select co nt.dcost) from soft$are) #2)Jho de=eloped the pac%age that has sold the least n mber of copies" a)select pname from soft$are $here sold'. A-3G1')*) or prof2')*).)*obol). D.pname) G-36 A-3C-26. 55)Jhat is the a=erage age of female programmers" a)select a=g.ccost) from st dies).**3/9) G-36 /9>DE.inst from st dies $here ccost'.ccost) from st dies) !()Jhich co rse has less than the a=erage n mber of st dents" a) !1)Display the names of the co rses $hose fees are $ithin 1&&&D< of the co rse" a)select co rse from st dies $here ccost?1&&&.cobol or pascal" a)select * from programer $here prof1 not in.)*obol).select maB. A-3G1 not in.co rse from st dies $here ccost?.).sysdate<doj)D3!5 from programer order by pname desc.*9 *3>79.*) from programer $here salary bet$een 2&&& and 4&&&.)Aascal)) 54)Fo$ old is the oldest male programmer" a)select maB./9>DE.dcost)from soft$are). !!)Jhich is the costiest co rse" a)select co rse from st dies $here ccost'.select maB.select maB. 51)Display the details of programmers %no$ing c" a)/.+. #3)Jhich lang age $as sed to de=elop the pac%age ha=ing highest cost" a)select de=:in from soft$are $here dcost'.sysdate<dob)D3!5 from programer $here seB')G) 5!)*alc late the eBperience in years for each programmer and siplay along $ith the names in descending order" a)select pname.select min. !#)Jhich instit te cond cts the costiest co rse" a)select co rse./.sysdate<dob)D3!5 from programer $here seB')6). 51)Jhat are the lang age %no$n by the male programmers" a)select prof1.dcost) from soft$are).-.+.*9 co nt.JF. D.select maB.)*).select a=g.)*lipper).*) from programer $here seB')G).*9 * G-36 A-3C-26.+. !&)Jhat is the a=erage salary" a)select a=g. #4)Fo$ many copies of the pac%ages that has the least difference bet$een de=elopemt and selling cost $ere sold" a) #5)Jhich lang age $as sed to de=elop the highest n mber of pac%ages" a) .)mm)). 53)Fo$ many programmers do not %no$ pascal U c" a)/.prof2 from programer $here seB')6). !2)Display the details of those $ho do not %no$ clipper.)Aascal)). 52)Fo$ many programmers %no$ either cobol or pascal" a)/.+.-. !1)Fo$ many people dra$ bet$een 2&&& and 4&&&" a)select co nt.*9 co nt. A-3G1')*obol) or prof2')Aascals).9E9+.

dob) from programer $here seB')6) and to:char.#!)Jhich programmer has de=eloped the highest n mber of pac%ages" a) ##)Jho is the a thor of costliest pac%age" a)select pname from soft$are $here dcost'.salary) from programer $here seB')G)) (5)Jho are the female programmers earning more than the highest paid male programmers" a)select pname from programer $here seB')G) and salary0. (1)Jho is the oldest female programmer $ho joined in 1112" a)select pname from programer $here dob'. instit te $ise" a) 1&1)En $hich instit te is the person $ho de=eloped the costilest pac%age" a) 1&2)Jhich lang age listed in prof1 and prof2 has not been sed to de=elop any pac%age" a) 1&3)Fo$ m ch does the person $ho de=eloped the highest selling pac%age earn and $hat co rse did heDshe ndergo" a) .)8888))'1112).dob.)8888))'11!5). (2)En $hich year $ere the most n mber of programmers $ere born" a) (3)En $hich lang age are most of the programmers proficient" a) (4)Jho are the male programmers earning belo$ the a=erage salary of the female programmers" a)select pname from programer $here seB')6) and salary?.salary) from programer $here seB')G)) (!)$hich lang age has been stated as profile by most of the programmers" a) (#)Display the details of those $ho are dra$ing the same salary" a) (()Display the details of the soft$are de=eloped by the male programmers earning more than 3&&&" a) (1)Display the details of the pac%ages de=eloped in pascal by female programmers" a) 1&)Display the details of the programmers $ho joined before 111&" a) 11)Display the details of the soft$are de=eloed in c by female programmers of pragathi" a) 12)Display the n mber of pac%ages.select maB. #()Display the names of the pac%ages $hich is sold less than the a=erage" a)select title from soft$are $here sold?.select maB.select a=g.sold) from soft$are).dob) from programer $here seB')G) and to:char.select maB. n mber of copies sold and sales =al e of each programmer instit te $ise" a) 13)Display the details of the soft$are de=eloped in Dbase by male programmers $ho belong to the instit te in $hich most n mber of programmers st died" a) 14)Display the details of soft$are de=eloped by the male programmers born after 11!5 and female programmers born before 11#5" a) 15)Display the details of the soft$are that $as de=eloped in the lang age $hich is neither the first nor the second proficiency of the programmers" a) 1!)Display the name of the programmers $ho ha=e not de=eloped any pac%age" a) 1#)Jhat is the total cost of the soft$are de=eloped by programmer by apple" a) 1()Jho are the programmer $ho joined in the same day" a) 11)Jho are the programmer $ho ha=e the same Arof"2" a) 1&&)Display the total sales =al e of soft$are. #1)Jho are the a thors of the pac%ages $hich ha=e reco=ered more than do ble the de=elopment cost" a) (&)Jho is the yo ngest male programmer born in 11!5" a)select pname from programer $here dob'.select a=g.select min.doj.dcost) from soft$are).

from soft$are table) and the instit tes they st died incl ding those $ho did not de=elop any pac%age" a) 112)+ist each prof $ith the n mber of programmers ha=ing that prof and the n mber of pac%ages de=eloped in that prof" a) 113)+ist the programmer names.seB.Bperience" a) 1&!)Jhat is the a=erage salary for those $hose soft$ares sales =al e is more than 5&&&&" a) 1&#)Fo$ many pac%ages $ere de=eloped by st dents $ho st died in instit te that charge the lo$est corse fee" a) 1&()Fo$ many pac%ages $ere de=eloped by the person $ho de=elped the cheapest pac%age and $here did sheDhe st dy from" a) 1&1)En ho$ many pac%ages female programmers are earning more than the male programmer" a) 11&)Fo$ many pac%ages $ere de=eloped by the most eBperienced programmer from bdps" a) 111)+ist the programmer. $itho t sing con=ersion f nction" a) 12!)Jho are the programmers $ho $ere born on the last day of the month" a) 12#)Jhat is the amo nt paid in salaries of the male programmers $ho don)t %no$ cobol" a) 12()Display the 9itle::::::::::::::::::::::2nd ::::::::::::::in descending order of differences" a) 121)Display the names of the pac%ages $hose names contains more than 1 $ord" a) 13&)Display the name.1&4)Fo$ many months $ill it ta%e for each programmer to reco=er the cost of the co rse heDshe nder$ent" a) 1&5)Jhich is the constiest pac%age de=eloped by a person $ith dnder 5 years .job.ddDmmDyy format)for all programmers.odj of those month of birth U month of joining are the same" a) .dob.from the programmer table) and the n mber of pac%ages each has de=eloped" a) 114)Display the details of those $ho $ill ha=e eBperience of 2 years of ser=ice this year" a) 115)*alc late the amo nt to be reco=ered for those pac%ages $hose de=elopment cost has not yet been reco=ered" a) 11!)+ist the pac%age $hich has not been sold so far" a) 11#)Gind o t the cost of the soft$are de=eloped by 6ary" a) 11()Display the instit te name from the st dies table $itho t d plicates" a) 111)Fo$ many different co rses are mentioned in the st dies table" a) 12&)Display the names of the programmers $hose names contain 2 conc rrence of the" a) 121)Display the names of programmers $hose names contaion pto 5 characters" a) 122)Fo$ many female programmers %no$ing cobol ha=e more than 2 years eBperience" a) 123)Jhat is the length of the shortest name in programmer table" a) 124)Jhat is the a=erage de=elopment cost of a pac%age de=eloped in cobol" a) 125)Display the name.