Академический Документы
Профессиональный Документы
Культура Документы
HOME
SqlQuerrys|AtoZ
CONTACTME
AtoZ
SqlQuerrys
Information
MAY
8UNDEFINED
BlogArchive
SearchThisBlog
Search
2015(4)
SQLQueries
2014(15)
1)Displaythedetailsofallemployees
2013(56)
a)select*fromemp
2012(52)
2)Displaythedepartinformactionfrom
departmenttable
2011(243)
December(32)
a)select*fromdept
November(26)
3)Displaythenameandjobforalltheemployees
October(7)
a)selectename,jobfromemp
September(11)
August(14)
4)Displaythenameandsalaryforallthe
employees
a)selectename,salfromemp
5)Displaytheemployeenoandtotalsalaryforall
theemployees
a)selectempno,sal+commastotalfromemp
May(24)
Comparing
DCOM,Remoting
andWebServices
6)Displaytheemployeenameandannualsalary
SQLInterviewQuations
forallemployees.
SSC2011RESULTS
andMArks
7)Displaythenamesofalltheemployeeswhoare
Labels
Ajax(33)
June(5)
.NETRemotingOrWeb
Services?
emp
2 2 3 6 4 9
July(21)
groupbyempno
a)selectename,sal*12asannualsalaryfrom
TotalPageviews
Followers
Jointhissite
withGoogleFriendConnect
Members(14)
commonjobinterview
questionswith
answersforev...
Alreadyamember?Signin
number10.
AndhrapradeshSSC
ResultsWithmarks
a)selectemamefromempwheredeptno=10
SSC2011REsults
8)Displaythenamesofalltheemployeeswhoare
andhrapradeshssc
2011results
workingasclerksand
TriggersSqlServer
Information
CREATETRIGGER
Viewmycompleteprofile
workingindepart
drawingasalarymorethan3000.
a)selectenamefromempwherejob='CLERKS'
andsal>3000
9)Displaytheemployeenumberandnamewho
areearningcomm.
a)selectempno,enamefromempwherecommis
notnull
10)Displaytheemployeenumberandnamewho
donotearnanycomm.
a)selectempno,enamefromempwherecommis
null
11)displaythenamesofemployeeswhoare
workingasclerks,salesmanor
(TransactSQL)
SQLServer2005:Get
fullinformationabout
transa...
Differencebetween
PrimaryKeyand
UniqueIndex
Whatisthedifference
betweenUNIONand
UNIONALL?...
CreatingDataView
A)selectenamefromempwherejob='CLERK'OR
method...
readaspradiobutton
listselectedvalue
Showgrandtotal
12)displaythenamesoftheemployeeswhoare
workinginthecompany
forthepast5years
a)selectenamefromempwhere
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
SqlQuerrys
SQLQueries1)Displaythe
detailsofallemployees
a)select*fromemp
2)Displaythedepart
informactionfrom
departmenttablea)sel...
RealTime
Scenario
Based
HowToCrossbrowser
analystanddrawingasalarymorethan3000.
JOB='ANALYST'ANDSAL>3000
PopularPosts
DataTableCreating,
Adding,Modi...
javascript
IsNumeric()
JOB='SALESMAN'OR
AboutMe
runningtotalDisplay
GridViewFo...
HowtoImportExcel
SpreadsheetData
Interview
Questions
HaiFriends,Asweknow
thatgettingmoreexperience
andthengoingforthe
interviewrequiresmore
knowledgeandifwesee,it
requiresm...
C#SortStringArray
Youneedtosortyour
1/20
4/24/2016
to_char(sysdate,'YYYY')
to_char(hiredate,'YYYY')>=5
13)Displaythelistofemployceeswhohavejoined
thecompanybefore
SqlQuerrys|AtoZ
intoSQLServ...
HowtobindaXMLfile
toaGridViewusing
Asp.net...
30JUN90orafter31DEC90.
DifferenceBetween
Int32.Parse(),
a)selectenamefromempwherehiredate<'30
ElectionResults
JUN1990'orhiredate>
SSC2011Results
Listorarrayofstringsusing
theC#programming
language.Youhaveasmall
ormediumnumberof
strings,meaningyo...
Convert.ToInt32(...
'31DEC90'
14)DisplaycurrentDate.
a)selectsysdatefromdual
15)Displaythelistofallusersinyour
database(usecatalogtable).
a)selectusernamefromall_users
16)Displaythenamesofalltablesfromcurrent
user
SqlQuerrys
Whatisthedifference
betweenDataGrid
andData...
April(102)
March(1)
AToZSoftwareSolutions.
PoweredbyBlogger.
a)selecttnamefromtab
AddCheckBoxInside
17)Displaythenameofthecurrentuser.
DataGridinC#windows
Application
a)showuser
Thisarticlewillexplainyou
18)Displaythenamesofemployeesworkingin
departnumber10or20or
40oremployeesworkingasCLERKS,SALESMAN
orANALYST.
a)Selectenamefromempwheredeptno
Home
howtoinsertCheckbox
insideDataGridViewin
windowsapplication.This
articleisforbeginners.First
crea...
InsertDatain
in(10,20,40)orjob
Dtabase
in('CLERKS','SALESMAN','ANALYST')
UsingWCF
Servicesin
19)Displaythenamesofemployeeswhosename
startswithalphabetS.
a)selectenamefromempwhereenamelike'S%'
20)DisplaytheEmployeenamesforemployees
ASP.Net
Introduction:HereIwill
explainhowtouseor
consumeWCF(windows
communicationfoundation)
whosenameendswithAlphabetS.
serviceinwebapplication
a)Selectenamefromempwhereenamelike
usingasp.net....
'%S'
DynamicallyAddNew
RowinGridView
21)Displaythenamesofemployeeswhose
UsingAsp.Net
nameshavesecondalphabetAintheirnames.
Introduction:Idecidedto
a)SelectenamefromEMPwhereenamelike'_A
writethisarticlebecause
%'
thishasbeenaskedso
manytimesbeforeatthe
22)selectthenamesoftheemployeewhose
forums(http://forums.asp.net)
namesisexactlyfive
.Basic...
Charactersinlength.
Readand
a)selectenamefromempwhere
WiriteData
length(ename)=5
InToMs
WordUsing
Asp.Net
23)Displaythenamesoftheemployeewhoare
notworkingasMANAGERS.
Inthisarticleiamgoingto
a)Selectenamefromempwherejobnotin
describehowtoreadand
('MANAGER')
writetomswordfileor
documentinASP.NETusing
24)Displaythenamesoftheemployeewhoare
notworkingasSALESMANORCLERKOR
ANALYST.
A)selectenamefromempwherejobnot
in('SALESMAN','CLERK','ANALYST')
25)DisplayallrowsfromEMPtable.Thesystem
shouldwaitaftereveryScreenfullofinformation.
a)Setpauseon
26)Displaythetotalnumberofemployeeworking
inthecompany.
a)Selectcount(*)fromEMP
27)Displaythetotalsalarybeigingpaidtoall
FileStream,StreamReader
andStr...
AndhrapradeshSSC
ResultsWithmarks
SSCResults
...................................................
.......................SSCResults
WithMarks
SendBulk
Emailsusing
C#VB.NET
inASP.NET
havebeen
askedzilliontimesthatHow
toSendBulkEmailsusing
C#orVB.NETinASP.NET.
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
2/20
4/24/2016
SqlQuerrys|AtoZ
employees.
Well,therearehundredsof
a)selectsum(sal)fromemp
tutorialsallove...
28)Displaythemaximumsalaryfromemptable.
a)selectmax(sal)fromemp
29)Displaytheminimumsalaryfromemptable.
a)selectmin(sal)fromemp
30)Displaytheaveragesalaryfromemptable.
a)selectavg(sal)fromemp
31)Displaythemaximumsalarybeingpaidto
CrystalReport:Formatting
CLERK.
theDecimalFieldinto
a)selectmax(sal)fromempwherejob='CLERK'
Integer
EventhoughIamcurrently
32)Displaythemaximumsalarybeingpaidto
workinginSharePointIstill
departnumber20.
haveafondofworkingin
a)selectmax(sal)fromempwheredeptno=20
crystalreports.Recentlyin
theMSDNforumsIsawa
33)Displaytheminimumsalarybeingpaidtoany
re...
SALESMAN.
a)selectmin(sal)fromempwhere
job='SALESMAN'
34)Displaytheaveragesalarydrawnby
MANAGERS.
a)selectavg(sal)fromempwhere
SubscribeTo
Posts
Comments
job='MANAGER'
35)DisplaythetotalsalarydrawnbyANALYST
Advertisement
workingindepartnumber
40.
a)selectsum(sal)fromempwherejob='ANALYST'
anddeptno=40
36)Displaythenamesoftheemployeeinorderof
salaryi.ethenameof
theemployeeearninglowestsalaryshouldsalary
appearfirst.
a)selectenamefromemporderbysal
37)Displaythenamesoftheemployeein
descendingorderofsalary.
a)selectenamefromemporderbysaldesc
38)Displaythenamesoftheemployeeinorderof
employeename.
a)selectenamefromemporderbyename
39)Displayempno,ename,deptno,salsortthe
outputfirstbaseonname
andwithinnamebydeptnoandwithindeptnoby
sal.
a)selectempno,ename,deptno,salfromemp
orderbyename,deptno,sal
40)Displaythenameoftheemployeealongwith
theirannualsalary(sal*
12).Thename
oftheemployeeearninghighestannualsalary
shouldapperfirst.
a)selectename,sal*12fromemporderbysal
desc
41)Displayname,salary,hra,pf,da,totalsalaryfor
eachemployee.The
outputshouldbein
theorderoftotalsalary,hra15%ofsalary,da10%
ofsalary,pf5%
salary,totalsalarywillbe(salary+hra+da)pf.
a)selectename,sal,sal/100*15ashra,sal/100*5as
pf,sal/100*10as
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
3/20
4/24/2016
SqlQuerrys|AtoZ
da,sal+sal/100*15+sal/100*10sal/100*5astotal
fromemp
42)Displaydepartnumbersandtotalnumberof
employeesworkingineach
department.
a)selectdeptno,count(deptno)fromempgroupby
deptno
43)Displaythevariousjobsandtotalnumberof
employeeswithineach
jobgroup.
a)selectjob,count(job)fromempgroupbyjob
44)Displaythedepartnumbersandtotalsalary
foreachdepartment.
a)selectdeptno,sum(sal)fromempgroupby
deptno
45)Displaythedepartnumbersandmaxsalary
foreachdepartment.
a)selectdeptno,max(sal)fromempgroupby
deptno
46)Displaythevariousjobsandtotalsalaryfor
eachjob
a)selectjob,sum(sal)fromempgroupbyjob
47)Displaythevariousjobsandtotalsalaryfor
eachjob
a)selectjob,min(sal)fromempgroupbyjob
48)Displaythedepartnumberswithmorethan
threeemployeesineach
dept.
a)selectdeptno,count(deptno)fromempgroupby
deptnohaving
count(*)>3
49)Displaythevariousjobsalongwithtotalsalary
foreachofthe
jobswheretotalsalaryisgreaterthan40000.
a)selectjob,sum(sal)fromempgroupbyjob
havingsum(sal)>40000
50)Displaythevariousjobsalongwithtotal
numberofemployeesin
eachjob.Theoutputshouldcontainonlythose
jobswithmorethanthree
employees.
a)selectjob,count(empno)fromempgroupbyjob
havingcount(job)>3
51)Displaythenameoftheempployeewhoearns
highestsalary.
a)selectenamefromempwheresal=(select
max(sal)fromemp)
52)Displaytheemployeenumberandnamefor
employeeworkingasclerk
andearninghighestsalaryamongclerks.
a)selectempno,enamefromempwherewhere
job='CLERK'andsal=(select
max(sal)fromempwherejob='CLERK')
53)Displaythenamesofsalesmanwhoearnsa
salarymorethanthe
highestsalaryofanyclerk.
a)selectename,salfromempwhere
job='SALESMAN'andsal>(select
max(sal)fromempwherejob='CLERK')
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
4/20
4/24/2016
SqlQuerrys|AtoZ
54)Displaythenamesofclerkswhoearnasalary
morethanthelowest
salaryofanysalesman.
A)selectenamefromempwherejob='CLERK'and
sal>(selectmin(sal)from
empwherejob='SALESMAN')
55)Displaythenamesofemployeeswhoearna
salarymorethanthatof
Jonesorthatofsalarygretherthanthatofscott.
a)selectename,salfromempwheresal>
(selectsalfromempwhereename='JONES')and
sal>(selectsalfromemp
whereename='SCOTT')
56)Displaythenamesoftheemployeeswhoearn
highestsalaryintheir
respectivedepartments.
a)selectename,sal,deptnofromempwheresal
in(selectmax(sal)from
empgroupbydeptno)
57)Displaythenamesoftheemployeeswhoearn
highestsalariesin
theirrespectivejobgroups.
a)selectename,sal,jobfromempwheresal
in(selectmax(sal)fromemp
groupbyjob)
58)Displaytheemployeenameswhoareworking
inaccountingdepartment.
a)selectenamefromempwheredeptno=(select
deptnofromdeptwhere
dname='ACCOUNTING')
59)Displaytheemployeenameswhoareworking
inChicago.
a)selectenamefromempwheredeptno=(select
deptnofromdeptwhere
LOC='CHICAGO')
60)DisplaytheJobgroupshavingtotalsalary
greaterthanthemaximum
salaryformanagers.
a)SELECTJOB,SUM(SAL)FROMEMPGROUPBYJOB
HAVINGSUM(SAL)>(SELECT
MAX(SAL)FROMEMPWHEREJOB='MANAGER')
61)Displaythenamesofemployeesfrom
departmentnumber10withsalary
gretherthanthatofanyemployeeworkingin
otherdepartment.
a)selectenamefromempwheredeptno=10and
sal>any(selectsalfromemp
wheredeptnonotin10).
62)Displaythenamesoftheemployeesfrom
departmentnumber10with
salarygreaterthanthatofallemployeeworking
inotherdepartments.
a)selectenamefromempwheredeptno=10and
sal>all(selectsalfromemp
wheredeptnonotin10).
63)Displaythenamesoftheemployeesin
Uppercase.
a)selectupper(ename)fromemp
64)Displaythenamesoftheemployeesin
Lowecase.
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
5/20
4/24/2016
SqlQuerrys|AtoZ
a)selectlower(ename)fromemp
65)Displaythenamesoftheemployeesin
Propercase.
a)selectinitcap(ename)fromemp
66)DisplaythelengthofYournameusing
appropriatefunction.
a)selectlength('name')fromdual
67)Displaythelengthofalltheemployeenames.
a)selectlength(ename)fromemp
68)selectnameoftheemployeeconcatenatewith
employeenumber.
selectename||empnofromemp
69)Userappropratefunctionandextract3
charactersstartingfrom2
charactersfromthefollowingstring'Oracle'.i.e
theoutputshouldbe
'ac'.
a)selectsubstr('oracle',3,2)fromdual
70)FindtheFirstoccuranceofcharacter'a'from
thefollowingstring
i.e'ComputerMaintenanceCorporation'.
a)SELECTINSTR('ComputerMaintenance
Corporation','a',1)FROMDUAL
71)ReplaceeveryoccuranceofalphabhetAwith
Binthestring
Allens(usetranslatefunction)
a)selecttranslate('Allens','A','B')fromdual
72)Displaytheinformactionfromemp
table.Wherejobmanagerisfound
itshouldbedisplayedasboos(Usereplace
function).
a)selectreplace(JOB,'MANAGER','BOSS')FROM
EMP
73)Displayempno,ename,deptnofromemp
table.Insteadofdisplay
departmentnumbersdisplaytherelated
departmentname(Usedecodefunction).
a)select
empno,ename,decode(deptno,10,'ACCOUNTING',2
0,'RESEARCH',30,'SALES',40,'OPRATIONS')from
emp
74)Displayyourageindays.
a)selectto_date(sysdate)to_date('10sep
77')fromdual
75)Displayyourageinmonths.
a)selectmonths_between(sysdate,'10sep77')
fromdual
76)Displaythecurrentdateas15thAugestFriday
NineteenNinety
Saven.
a)selectto_char(sysdate,'ddthMonthdayyear')
fromdual
77)Displaythefollowingoutputforeachrowfrom
emptable.
78)scotthasjoinedthecompanyonwednesday
13thAugustnintennintey.
a)selectENAME||'HASJOINEDTHECOMPANYON
'||to_char(HIREDATE,'day
ddthMonthyear')fromEMP
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
6/20
4/24/2016
SqlQuerrys|AtoZ
79)Findthedatefornearestsaturdayafter
currentdate.
a)SELECTNEXT_DAY(SYSDATE,'SATURDAY')FROM
DUAL
80)displaycurrenttime.
a)selectto_char(sysdate,'hh:MM:ss')fromdual.
81)DisplaythedatethreemonthsBeforethe
currentdate.
a)selectadd_months(sysdate,3)fromdual
82)Displaythecommonjobsfromdepartment
number10and20.
a)selectjobfromempwheredeptno=10andjob
in(selectjobfromemp
wheredeptno=20)
83)Displaythejobsfoundindepartment10and
20Eliminateduplicate
jobs.
a)selectdistinct(job)fromempwheredeptno=10
ordeptno=20
or
selectdistinct(job)fromempwheredeptno
in(10,20)
84)Displaythejobswhichareuniqueto
department10.
a)selectdistinct(job)fromempwheredeptno=10
85)Displaythedetailsofthosewhodonothave
anypersonworking
underthem.
a)selecte.enamefromemp,empewhere
emp.mgr=e.empnogroupbye.ename
havingcount(*)=1
86)Displaythedetailsofthoseemployeeswho
areinsalesdepartment
andgradeis3.
a)
select*fromempwheredeptno=(select
deptnofromdeptwhere
dname='SALES')and
salbetween(selectlosalfromsalgrade
wheregrade=3)and
(selecthisalfromsalgradewhere
grade=3)
87)Displaythosewhoarenotmanagersandwho
aremanagersanyone.
i)displaythemanagersnames
a)selectdistinct(m.ename)fromempe,empm
wherem.empno=e.mgr
ii)displaythewhoarenotmanagers
a)selectenamefromempwhereenamenot
in(selectdistinct(m.ename)
fromempe,empmwherem.empno=e.mgr)
88)Displaythoseemployeewhosenamecontains
notlessthan4
characters.
a)selectenamefromempwhere
length(ename)>4
89)Displaythosedepartmentwhosenamestart
with"S"whilethe
locationnameendswith"K".
a)selectdnamefromdeptwherednamelike'S%'
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
7/20
4/24/2016
SqlQuerrys|AtoZ
andloclike'%K'
90)Displaythoseemployeeswhosemanager
nameisJONES.
a)selectp.enamefromempe,emppwhere
e.empno=p.mgrand
e.ename='JONES'
91)Displaythoseemployeeswhosesalaryismore
than3000aftergiving
20%increment.
a)selectename,salfromempwhere
(sal+sal*.2)>3000
92)Displayallemployeeswhiletheirdeptnames
s)selectename,dnamefromemp,deptwhere
emp.deptno=dept.deptno
93)Displayenamewhoareworkinginsalesdept.
a)selectenamefromempwheredeptno=(select
deptnofromdeptwhere
dname='SALES')
94)Displayemployeename,deptname,salaryand
commforthosesalin
between2000to5000whilelocationischicago.
a)selectename,dname,sal,commfromemp,dept
wheresalbetween2000and
5000andloc='CHICAGO'and
emp.deptno=dept.deptno
95)Displaythoseemployeeswhosesalarygreter
thanhismanagersalary.
a)selectp.enamefromempe,emppwhere
e.empno=p.mgrandp.sal>e.sal
96)Displaythoseemployeeswhoareworkingin
thesamedeptwherehis
manageriswork.
a)selectp.enamefromempe,emppwhere
e.empno=p.mgrand
p.deptno=e.deptno
97)Displaythoseemployeeswhoarenotworking
underanymanager.
a)selectenamefromempwheremgrisnull
98)Displaygradeandemployeesnameforthe
deptno10or30butgrade
isnot4whilejoinedthecompanybefore31dec
82.
a)selectename,gradefromemp,salgradewhere
salbetweenlosalandhisalanddeptnoin(10,30)
andgrade<>4andhiredate<'31DEC82'
99)Updatethesalaryofeachemployeeby10%
incrementwhoarenoteligiblwforcommission.
a)updateempsetsal=sal+sal*10/100where
commisnull
100)SELECTthoseemployeewhojoinedthe
companybefore31dec82whiletheirdept
locationisnewyorkorChicago.
a)SELECTEMPNO,ENAME,HIREDATE,DNAME,LOC
FROMEMP,DEPTWHERE
(EMP.DEPTNO=DEPT.DEPTNO)AND
HIREDATE<'31DEC82'ANDDEPT.LOC
IN('CHICAGO','NEWYORK')
101)DISPLAYEMPLOYEE
NAME,JOB,DEPARTMENT,LOCATIONFORALLWHO
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
8/20
4/24/2016
SqlQuerrys|AtoZ
ARE
WORKINGASMANAGER?
A)selectename,JOB,DNAME,LOCATIONfrom
emp,DEPTwheremgrisnotnull
102)dISPLAYTHOSEEMPLOYEESWHOSE
MANAGERNAMEISJONES?[ANDALSO
DISPLAYTHEIRMANAGERNAME]?
A)SELECTP.ENAMEFROMEMPE,EMPPWHERE
E.EMPNO=P.MGRAND
E.ENAME='JONES'
103)Displaynameandsalaryoffordifhissalary
isequaltohisalof
hisgrade
a)selectename,sal,gradefromemp,salgrade
wheresalbetweenlosaland
hisal
andename='FORD'ANDHISAL=SAL
104)Displayemployeename,job,departname
,managername,hisgradeand
makeoutanunderdepartmentwise?
a)SELECT
E.ENAME,E.JOB,DNAME,EMP.ENAME,GRADEFROM
EMP,EMP
E,SALGRADE,DEPT
WHEREEMP.SALBETWEENLOSALANDHISAL
ANDEMP.EMPNO=E.MGRAND
EMP.DEPTNO=DEPT.DEPTNOORDERBYDNAME
105)Listoutallemployeesname,job,salary,grade
anddepartnameforeveryoneinthecompany
except'CLERK'.Sortonsalarydisplaythehighest
salary?
a)SELECTENAME,JOB,DNAME,SAL,GRADEFROM
EMP,SALGRADE,DEPTWHERE
SALBETWEENLOSALANDHISALAND
EMP.DEPTNO=DEPT.DEPTNOANDJOBNOT
IN('CLERK')ORDERBYSALASC
106)Displaytheemployeename,jobandhis
manager.Displayalsoemployeewhoarewithout
manager?
a)selecte.ename,e.job,eMP.enameASManager
fromemp,empewhereemp.empno(+)=e.mgr
107)Findoutthetop5earnersofcompany?
a)SELECTDISTINCTSALFROMEMPEWHERE
5>=(SELECTCOUNT(DISTINCTSAL)
FROMEMPAWHEREA.SAL>=E.SAL)ORDERBY
SALDESC
108)Displaynameofthoseemployeewhoare
gettingthehighestsalary?
a)selectenamefromempwheresal=(select
max(sal)fromemp)
109)Displaythoseemployeewhosesalaryis
equaltoaverageofmaximum
andminimum?
a)selectenamefromempwheresal=(select
max(sal)+min(sal)/2from
emp)
110)Selectcountofemployeeineachdepartment
wherecountgreaterthan3?
a)selectcount(*)fromempgroupbydeptno
havingcount(deptno)>3
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
9/20
4/24/2016
SqlQuerrys|AtoZ
111)Displaydnamewhereatleast3areworking
anddisplayonly
departmentname?
a)selectdistinctd.dnamefromdeptd,empe
whered.deptno=e.deptnoand
3>any(selectcount(deptno)fromempgroupby
deptno)
112)Displaynameofthosemanagersname
whosesalaryismorethanaveragesalaryofhis
company?
a)SELECTE.ENAME,EMP.ENAMEFROMEMP,EMPE
WHEREEMP.EMPNO=E.MGRAND
E.SAL>(SELECTAVG(SAL)FROMEMP)
113)Displaythosemanagersnamewhosesalary
ismorethanaveragesalaryofhisemployee?
a)SELECTDISTINCTEMP.ENAMEFROMEMP,EMPE
WHEREE.SAL<(SELECTAVG(EMP.SAL)FROM
EMP
WHEREEMP.EMPNO=E.MGRGROUPBY
EMP.ENAME)ANDEMP.EMPNO=E.MGR
114)Displayemployeename,sal,commandnet
payforthoseemployeewhosenetpayisgreter
thanorequaltoanyotheremployeesalaryof
thecompany?
a)selectename,sal,comm,sal+nvl(comm,0)as
NetPayfromempwheresal+nvl(comm,0)>any
(selectsalfromemp)
115)Displaythoseemployeeswhosesalaryisless
thanhismanagerbutmorethansalaryofany
othermanager?
a)
116)Displayallemployeesnameswithtotalsalof
companywitheach
employeename?
a)SELECTENAME,(SELECTSUM(SAL)FROMEMP)
FROMEMP
117)Findoutlast5(least)earnersofthe
company.?
a)SELECTDISTINCTSALFROMEMPEWHERE
5>=(SELECTCOUNT(DISTINCTSAL)
FROMEMPAWHEREA.SAL<=E.SAL)ORDERBY
SALDESC
118)Findoutthenumberofemployeeswhose
salaryisgreaterthantheirmanagersalary?
a)SELECTE.ENAMEFROMEMP,EMPEWHERE
EMP.EMPNO=E.MGRAND
EMP.SAL<E.SAL
119)Displaythosemanagerwhoarenotworking
underpresidentbuttheyareworkingunderany
othermanager?
a)
120)Displaythosedepartmentwhereno
employeeworking?
a)selectdnamefromemp,deptwhere
emp.deptnonotin(emp.deptno)
121)deletethoserecordsfromemptablewhose
deptnonotavailableindepttable.
a)
122)Displaythoseenameswhosesalaryisoutof
thegradeavailableinsalgradetable.
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
10/20
4/24/2016
SqlQuerrys|AtoZ
a)
123)Displayemployeename,sal,commandwhose
netpayisgreaterthan
anyotherinthecompany?
a)
124)Displaynameofthoseemployeewhoare
goingtoretrie31DEC99.
ifthemaximumjobperiodis30years?
a)
125)DisplaythoseemployeewhosesalaryisODD
value?
a)select*fromempwheresal<0
126)Displaythoseemployeewhosesalary
containsalleast3digits?
a)select*fromempwherelength(sal)>=3
127)Displaythoseemployeewhojoinedinthe
companyinthemonthof
Dec?
a)selectenamefromempwhere
to_char(hiredate,'MON')='DEC'
128)Displaythoseemployeeswhosename
contains"A"?
a)selectenamefromempwhere
instr(ename,'A')>0
or
selectenamefromempwhereenamelike('%A
%')
129)Displaythoseemployeewhosedeptnois
availableinsalary?
a)selectemp.enamefromemp,empewhere
emp.sal=e.deptno
130)Displaythoseemployeewhosefirst2
charactersfromhiredatelast
2charactersofsalary?
a)selectename,SUBSTR(hiredate,1,2)||ENAME||
substr(sal,2,2)fromemp
131)Displaythoseemployeewhose10%ofsalary
isequaltotheyearof
joining?
a)selectenamefromempwhere
to_char(hiredate,'YY')=sal*0.1
132)Displaythoseemployeewhoareworkingin
salesorresearch?
a)SELECTENAMEFROMEMPWHEREDEPTNO
IN(SELECTDEPTNOFROMDEPTWHERE
DNAMEIN('SALES','RESEARCH'))
133)Displaythegradeofjones?
a)SELECTENAME,GRADEFROMEMP,SALGRADE
WHERESALBETWEENLOSALAND
HISALANDEname='JONES'
134)Displaythoseemployeeswhojoinedthe
companybefore15ofthe
month?
a)selectenamefromempwhere
to_char(hiredate,'DD')<15
135)Displaythoseemployeewhohasjoined
before15thofthemonth.
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
11/20
4/24/2016
SqlQuerrys|AtoZ
a)selectenamefromempwhere
to_char(hiredate,'DD')<15
136)Deletethoserecordswherenoofemployees
inaparticular
departmentislessthan3.
a)deletefromempwheredeptno=(selectdeptno
fromemp
groupbydeptnohavingcount(deptno)<3)
137)Displaythedepartmentnamethenoof
charactersofwhich
isequaltonoofemployeeinanyother
department.
a)
138)Displaythenameofthedepartmentwhere
noemployeeworking.
a)
139)Displaythoseemployeeswhoareworkingas
manager.
a)
140)Countthenoofemployeeswhoareworking
asmanager(usingset
operations).
a)
141)Displaythenameofthedeptthoseemployee
whojoinedthecompany
onthesamedate?
a)
142)Displaythoseemployeeswhosegradeis
equaltoanynumberofsal
butnotequaltofirstnumberofsal?
a)
143)Countthenoofempployeeworkingas
managerusingsetoperaction?
a)
144)displaythenameoftheemployeeswho
joinedthesamedate.
a)
145)Displaythemanagerwhoishavingmaximum
numberofemployeesworkingunderhim?
a)
146)listoutemployeenameandsalaryincreased
by15%andexpressedaswholenumberof
Dollars?
a)
147)Producetheoutputoftheemptable"EMPLOYEEANDJOB"forenameandjob?a)
148)Listallemployeewithhiredateintheformat
'june41988'?
a)
149)Printlostofemployeesdisplaying"just
salary"ifmorethan1500
ifexactly1500display'Ontarget'iflessthan
1500Displaybelow1500?
A)selectename,sal,(casewhensal>1500then
'Below_target'when
sal=1500then'On_targer'whensal<1500then
'lessthantarget'else'kkkkk'end)fromemp
150)WHICHquerytocalcuatethelengthoftime
anyemployeehasbeenwiththecompany?
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
12/20
4/24/2016
SqlQuerrys|AtoZ
151)Giveastringoftheformat'nn/nn'Verifythat
thefirstandlast
2charactersarenumbers.Andthatthemiddle
characteris'/'Printthe
exprection'Yes'ifvalid'No'ofnotvalidUsethe
followingvaluestotestyoursoluction'$12/54(Not
clear).
a)
152)Employeehireon15thofanymontharepaid
onthelastFridayofthatmonth.Thosehiredafter
15tharepaidthelastFridayofthefollowing
month.Printalistofemployees.theirhiredate
andfirstpaydatescortthosewhosesalary
containsfirstdigitsoftheirdeptno?
a)
select
ename,hiredate,last_day(next_day(hiredate,'FRID
AY')),deptno,
(casewhento_char(hiredate,'DD')<=15then
last_day(next_day(hiredate,'FRIDAY'))
whento_char(hiredate,'DD')>15then
last_day(next_day(add_months(hiredate,1),'FRIDA
Y'))
end
)fromemporderbysubstr(sal,0,2)
153)Displaythosemanagerwhoaregettingless
thanhisemployee
salary?
a)
154)Printthedetailsofalltheemployeeswhoare
Subordinateto
BLAKE?
a)selectemp.enamefromemp,empewhere
emp.mgr=e.empnoand
e.ename='BLAKE'
155)Displaythosewhoareworkingasmanager
usingCOrelatesubquery?
a)
156)Displaythoseemployeewhosemanager
nameisjonesandalsowithhismanagername?
a)
157)Definevariablerepresentingtheexpression
usedtocalculateon
employeetotalAnnualRemunatation?
a)
158)Usethevariableinastatementwhichfinds
allemployeeswhocanearn$30,000ayearor
more?
a)
159)Findouthowmanymanagersaretherewith
outlistingthem?
a)
160)Findouttheaveragesalaryandaveragetotal
remunerationforeachjobtyperemembersales
manearncommission?
a)
161)Checkwhetherallemployeesnumberare
indeedunique?
a)
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
13/20
4/24/2016
SqlQuerrys|AtoZ
162)Listoutthelowestpaidemployeesworking
foreachmanagerexcludeanygroupswhere
minimumsalaryislessthanRs.1000Sortthe
outputbysalary?
a)
163)Listename,job,annualsal,deptno,dnameand
gradewhoearn$36,000ayearorwhoarenot
Clerks?
a)
164)Findoutthejobthatwasfailedinthefirsthalf
of1983andsame
jobthatwasfailedduringthesameperiodon
1984?
a)
165)Findouttheemployeeswhojoinedthe
companybeforetheirmanager?
a)
166)Listoutalltheemployeesbynameand
numberalongwiththeir
manager'snameandnumberalsodisplay%NG
whohasnomanager?
a)
167)Findouttheemployeewhoearnedthe
highestsalaryineachjob
typeSortindesendingsalaryorder?
a)
168)Findouttheemployeeswhoearnedthe
minimumsalaryfortheirjobinAssendingorder?
a)
169)Findoutthemostresentlyhiredemployees
ineachdepartmentOrderbyhiredate?
a)
170)Displayename,salaryanddeptnoforeach
employeewhoearnasalarygreaterthanthe
averageforthendepartmentorderbydeptno?
a)
171)Displaythedepartmentwherethereareno
employees?
a)
172)Displaythedepartmentnowithhighest
annualremunarationbillascompensation?
a)
173)Inwhichyeardidmostpeoplejointhe
companyDisplaytheyearandnumberof
employees?
a)
174)Displaytheaveragesalaryfigureforthe
department?
a)selectavg(SAL)fromempgroupbydeptno
175)Writeaqueryofdisplayagainsttherowof
themostrecentlyhiredemployeesDisplayename
Hiredateandcolumnmaxdateshowing
a)
176)Displayemployeewhocanearnmorethan
lowestsalaryindepartmentno30?
a)
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
14/20
4/24/2016
SqlQuerrys|AtoZ
177)Findemployeeswhocanearnmorethan
everyemployeeindeptno?
a)
178)Selectdeptnamedeptnoandsumofsalary?
a)
179)Findoutaveragesalaryandaveragetotal
remaindersforeachjobtype?
a)
180)Findalldepartmentswhichhavemorethan3
employees?
a)
181)Checkwhetheremployeesnumberare
unique?
a)
182)Listlowestpaidemployeesworkingforeach
managerexcludeany
groupswheretheminimumsalarylessthan1000.
Sorttheoutputby
salary?
a)
183)Ifthepaydayisnextfridayafter15thand
30thofevery
month.whatisthenextpaydayfromtheirhire
dateforemployeeinemptable?
a)
184)Ifanemployeeistakenbyyoutodayinyour
organisation.
Anditisapolicyinyourcompanytohavea
reviewafter9monthsthe
joineddate(andof1stofnextmonthafter9
months)howmanydaysfromtodayyour
employeeshasTowaitforareview?
a)
185)Displayemployeenameandhissalarywhose
salaryisgreaterthanhighestaverageof
departmentnumber?
a)SELECTSALFROMEMPWHERESAL>(SELECT
MAX(AVG(SAL))FROMEMPGROUPBY
DEPTNO)
186)Displaythe10threcordofemptable(without
usingrowid)
a)
SELECT*FROMEMPWHERE
ROWNUM<11
MINUS
SELECT*FROMEMPWHERE
ROWNUM<10
187)Displaythehalfoftheename'sinuppercase
andremaining
lowercase?
a)
SELECT
SUBSTR(LOWER(ENAME),1,3)||
SUBSTR(UPPER(ENAME),3,LENGTH(ENAME))FROM
EMP
188.
Displaythe10threcordofemptable
withoutusinggroupbyandrowid?
A)
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
15/20
4/24/2016
SqlQuerrys|AtoZ
SELECT*FROMEMPWHERE
ROWNUM<11
MINUS
SELECT*FROMEMPWHERE
ROWNUM<10
189.
Deletethe10threcordofemptable.
A)
DELETEFROMEMPWHERE
EMPNO=(SELECTEMPNOFROMEMPWHERE
ROWNUM<11
MINUS
SELECTEMPNOFROMEMPWHERE
ROWNUM<10)
190.
Createacopyofemptable
a)
createtablenew_tableasselect*from
empwhere1=2
191.
Selectenameifenameexistsmorethan
once.
a)
selectenamefromempegroupby
enamehavingcount(*)>1
192.
Displayallenamesinreverseorder?
(SMITH:HTIMS).
a)
SELECTREVERSE(ENAME)FROMEMP
193.
Displaythoseemployeewhosejoiningof
monthandgradeisequal.
A)
SELECTENAMEFROMEMPWHERESAL
BETWEEN(SELECTLOSALFROMSALGRADE
WHEREGRADE=TO_CHAR(HIREDATE,'MM'))AND
(SELECTHISALFROMSALGRADEWHERE
GRADE=TO_CHAR(HIREDATE,'MM'))
194.
Displaythoseemployeewhosejoining
DATEisavailableindeptno.
A)
SELECTENAMEFROMEMPWHERE
TO_CHAR(HIREDATE,'DD')=DEPTNO
195.
Displaythoseemployeesnameas
follows
AALLEN
BBLAKE
A)
SELECTSUBSTR(ENAME,1,1),ENAME
FROMEMP
196.
Listouttheemployees
ename,sal,PF(20%OFSAL)fromemp
A)
SELECTENAME,SAL,SAL*.2ASPFFROM
EMP
197.
DisplayRSPSfromempwithoutusing
updatinginserting.
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
16/20
4/24/2016
SqlQuerrys|AtoZ
A)
198.
Createtableempwithonlyonecolumn
empno
A)
createtableempasselectempnofrom
empwhere1=2
199.
Addthiscolumntoemptableename
vrachar2(20).
a)
altertableempadd(ename
varchar2(20))
200.
OopsIforgotgivetheprimarykey
constraint.Addinnow.
a)
altertableempaddprimary
key(empno)
201.
Nowincreasethelengthofename
columnto30characters.
a)
altertableempmodify(ename
varchar2(30))
202.
Addsalarycolumntoemptable.
altertableempadd(salnumber(10))
203.
Iwanttogiveavalidationsayingthat
salarycannotbegreater
10,000(notegiveanametothisconstraint)
a)
altertableempaddconstraintchk_001
check(sal<=10000)
204.
ForthetimebeingIhavedecidedthatI
willnotimposethis
validation.
Mybosshasagreedtopaymorethan
10,000.
a)
againalterthetableordropconstraint
with
altertableempdropconstraint
chk_001(or)Disabletheconstraintby
using
a)
119)Howmanydifferentcoursesarementionedin
thestudiestable.
a)
120)Displaythenamesoftheprogrammers
whosenamescontain2
concurrenceofthe.
a)
121)Displaythenamesofprogrammerswhose
namescontaionupto5
characters.
a)
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
17/20
4/24/2016
SqlQuerrys|AtoZ
122)Howmanyfemaleprogrammersknowing
cobolhavemorethan2years
experience.
a)
123)Whatisthelengthoftheshortestnamein
programmertable.
a)
124)Whatistheaveragedevelopmentcostofa
packagedevelopedin
cobol.
a)
125)Displaythename,sex,dob(dd/mm/yy
format)forallprogrammers,
withoutusingconversionfunction.
a)
126)Whoaretheprogrammerswhowerebornon
thelastdayofthemonth.
a)
127)Whatistheamountpaidinsalariesofthe
maleprogrammerswhodon'tknowcobol.
a)
128)DisplaytheTitle______________________And
______________indescendingorderofdifferences.
a)
129)Displaythenamesofthepackageswhose
namescontainsmorethan1word.
a)
130)Displaythename,job,odjofthosemonthof
birth&monthofjoiningarethesame.
a)
PreviousNext
268p.
15p.
RecentReadcasters
SumitPalan
HuseinBhinderwala
AddaComment
17comments:
mahetarirfansaid...
findoutallemployeesnameandsalarywhoisworkinginSMITHdepartmentasmanager
31August2015at10:34
mahetarirfansaid...
plsgivequeryforthis
31August2015at10:34
Unknownsaid...
SELECTENAME,SALFROMEMPWHEREENAME='SMITH'ANDJOB='MANAGER'
9September2015at01:05
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
18/20
4/24/2016
SqlQuerrys|AtoZ
SpRajusaid...
SELECTENAME,SALFROMEMPWHEREENAME='SMITH'ANDJOB='MANAGER'
9September2015at01:10
SatishkumarKurapatisaid...
selectename,salfromempwhereename='smith'andjob='manager'
23October2015at19:59
Unknownsaid...
DisplayalltheemployeenamesinResearchandSales
Departmentwhoarehavingatleast1personreportingto
them
needsqlquerypleasehelpme
3November2015at11:03
BilalAhmadsaid...
Plzhelpmeinthisquery...
Displaynameoftheemployeeswhosnamestartswithaandhaseassecondlast
character.
1December2015at08:43
ARCHANAKUMARIsaid...
Selectnamefromemployeewherenamelike'a%'and'%e_'
2December2015at02:52
ARCHANAKUMARIsaid...
Thiscommenthasbeenremovedbytheauthor.
2December2015at02:53
elifzersaid...
Thiscommenthasbeenremovedbytheauthor.
2December2015at11:13
ajaytallurisaid...
hiiineedahelpforthisquerry
querry:
listalltheemployeeshavingthesamejobasemployeesinchicago
4February2016at11:01
AtulJadhavsaid...
Selectemployee_ID,Job_IDfromemployeewhereJob_Locationlike'Chicago'
15February2016at23:45
SatheeshSaharasaid...
Querytodisplaydeptno,sum(max(sal))ofoveralldeptnoandcorespondingdname
21February2016at23:28
SatheeshSaharasaid...
Thiscommenthasbeenremovedbytheauthor.
21February2016at23:28
AJITKUMARsaid...
writeaquerryforSMITHISCLERK
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
19/20
4/24/2016
SqlQuerrys|AtoZ
29February2016at23:12
SANDEEPsaid...
Thiscommenthasbeenremovedbytheauthor.
29March2016at21:46
SANDEEPsaid...
Thiscommenthasbeenremovedbytheauthor.
29March2016at21:51
PostaComment
Enteryourcomment...
Commentas:
Publish
GoogleAccount
Preview
Linkstothispost
CreateaLink
NewerPost
Home
OlderPost
Subscribeto:PostComments(Atom)
2010CopyrightAtoZAllrightsreserved.
DesignedbyTemplatelite.ConvertedToBloggerTemplatebyAnshul.
http://challlengebrains.blogspot.in/2011/05/sqlquerrys.html
20/20