Sei sulla pagina 1di 20

4/24/2016

SqlQuerrys|AtoZ

Information

SQLQueries

1)Displaythedetailsofallemployees

a)select*fromemp;

2)Displaythedepartinformactionfrom

departmenttable

a)select*fromdept;

3)Displaythenameandjobforalltheemployees

a)selectename,jobfromemp;

4)Displaythenameandsalaryforallthe

employees

a)selectename,salfromemp;

5)Displaytheemployeenoandtotalsalaryforall

theemployees

a)selectempno,sal+commastotalfromemp

groupbyempno;

6)Displaytheemployeenameandannualsalary

forallemployees.

a)selectename,sal*12asannualsalaryfrom

emp;

7)Displaythenamesofalltheemployeeswhoare

workingindepart

number10.

a)selectemamefromempwheredeptno=10;

8)Displaythenamesofalltheemployeeswhoare

workingasclerksand

drawingasalarymorethan3000.

a)selectenamefromempwherejob='CLERKS'

andsal>3000;

9)Displaytheemployeenumberandnamewho

areearningcomm.

a)selectempno,enamefromempwherecommis

notnull;

10)Displaytheemployeenumberandnamewho

donotearnanycomm.

a)selectempno,enamefromempwherecommis

null;

11)displaythenamesofemployeeswhoare

workingasclerks,salesmanor

analystanddrawingasalarymorethan3000.

A)selectenamefromempwherejob='CLERK'OR

JOB='SALESMAN'OR

JOB='ANALYST'ANDSAL>3000;

12)displaythenamesoftheemployeeswhoare

workinginthecompany

forthepast5years;

a)selectenamefromempwhere

MAY

8UNDEFINED

BlogArchive

2014(15)

2013(56)

2012(52)

2011(243)

July(21)

SearchThisBlog Search
SearchThisBlog
Search

TotalPageviews

2 2 3 6 4 9
2
2
3
6
4
9

Ajax(33)

Labels

4/24/2016

SqlQuerrys|AtoZ

to_char(sysdate,'YYYY')­

to_char(hiredate,'YYYY')>=5;

13)Displaythelistofemployceeswhohavejoined

thecompanybefore

30­JUN­90orafter31­DEC­90.

a)selectenamefromempwherehiredate<'30­

JUN­1990'orhiredate>

'31­DEC­90';

14)DisplaycurrentDate.

a)selectsysdatefromdual;

15)Displaythelistofallusersinyour

database(usecatalogtable).

a)selectusernamefromall_users;

16)Displaythenamesofalltablesfromcurrent

user;

a)selecttnamefromtab;

17)Displaythenameofthecurrentuser.

a)showuser

18)Displaythenamesofemployeesworkingin

departnumber10or20or

40oremployeesworkingasCLERKS,SALESMAN

orANALYST.

a)Selectenamefromempwheredeptno

in(10,20,40)orjob

in('CLERKS','SALESMAN','ANALYST');

19)Displaythenamesofemployeeswhosename

startswithalphabetS.

a)selectenamefromempwhereenamelike'S%';

20)DisplaytheEmployeenamesforemployees

whosenameendswithAlphabetS.

a)Selectenamefromempwhereenamelike

'%S';

21)Displaythenamesofemployeeswhose

nameshavesecondalphabetAintheirnames.

a)SelectenamefromEMPwhereenamelike'_A

%';

22)selectthenamesoftheemployeewhose

April(102)

AToZSoftwareSolutions.

PoweredbyBlogger.

Listorarrayofstringsusing

theC#programming

language.Youhaveasmall

ormediumnumberof

strings,meaningyo

language.Youhaveasmall ormediumnumberof strings,meaningyo AddCheckBoxInside DataGridinC#windows Application

Thisarticlewillexplainyou

howtoinsertCheckbox

insideDataGridViewin

windowsapplication.This

articleisforbeginners.First

crea

InsertDatain
 

Introduction:HereIwill

explainhowtouseor

consumeWCF(windows

communicationfoundation)

serviceinwebapplication

usingasp.net

DynamicallyAddNew

Introduction:Idecidedto

writethisarticlebecause

thishasbeenaskedso

manytimesbeforeatthe

forums(http://forums.asp.net)

namesisexactlyfive

.Basic

.Basic
 

Charactersinlength.

a)selectenamefromempwhere

length(ename)=5;

23)Displaythenamesoftheemployeewhoare

notworkingasMANAGERS.

Inthisarticleiamgoingto

a)Selectenamefromempwherejobnotin

describehowtoreadand

('MANAGER');

writetomswordfileor

24)Displaythenamesoftheemployeewhoare

notworkingasSALESMANORCLERKOR

ANALYST.

A)selectenamefromempwherejobnot

in('SALESMAN','CLERK','ANALYST');

25)DisplayallrowsfromEMPtable.Thesystem

shouldwaitaftereveryScreenfullofinformation.

a)Setpauseon

26)Displaythetotalnumberofemployeeworking

inthecompany.

a)Selectcount(*)fromEMP;

27)Displaythetotalsalarybeigingpaidtoall

documentinASP.NETusing

FileStream,StreamReader

andStr

SSCResults

SSCResults

WithMarks

SSCResults SSCResults WithMarks SendBulk Emailsusing C#VB.NET inASP.NET havebeen

havebeen

askedzilliontimesthatHow

toSendBulkEmailsusing

C#orVB.NETinASP.NET.

4/24/2016

SqlQuerrys|AtoZ

employees. a)selectsum(sal)fromemp;

28)Displaythemaximumsalaryfromemptable.

a)selectmax(sal)fromemp;

29)Displaytheminimumsalaryfromemptable.

a)selectmin(sal)fromemp;

30)Displaytheaveragesalaryfromemptable.

a)selectavg(sal)fromemp;

31)Displaythemaximumsalarybeingpaidto

CLERK.

a)selectmax(sal)fromempwherejob='CLERK';

32)Displaythemaximumsalarybeingpaidto

departnumber20.

a)selectmax(sal)fromempwheredeptno=20;

33)Displaytheminimumsalarybeingpaidtoany

SALESMAN.

a)selectmin(sal)fromempwhere

job='SALESMAN';

34)Displaytheaveragesalarydrawnby

MANAGERS.

a)selectavg(sal)fromempwhere

job='MANAGER';

35)DisplaythetotalsalarydrawnbyANALYST

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

Well,therearehundredsof

tutorialsallove

pf,sal/100*10as Well,therearehundredsof tutorialsallove CrystalReport:Formatting theDecimalFieldinto Integer

EventhoughIamcurrently

workinginSharePointIstill

haveafondofworkingin

crystalreports.Recentlyin

theMSDNforumsIsawa

re

SubscribeTo

Postscrystalreports.Recentlyin theMSDNforumsIsawa re SubscribeTo Comments Advertisement

theMSDNforumsIsawa re SubscribeTo Posts Comments Advertisement

CommentstheMSDNforumsIsawa re SubscribeTo Posts Advertisement

theMSDNforumsIsawa re SubscribeTo Posts Comments Advertisement

Advertisement

4/24/2016

SqlQuerrys|AtoZ

da,sal+sal/100*15+sal/100*10­sal/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');

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.

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('10­sep­

77')fromdual

75)Displayyourageinmonths.

a)selectmonths_between(sysdate,'10­sep­77')

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;

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%'

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

isnot4whilejoinedthecompanybefore31­dec­

82.

a)selectename,gradefromemp,salgradewhere

salbetweenlosalandhisalanddeptnoin(10,30)

andgrade<>4andhiredate<'31­DEC­82';

99)Updatethesalaryofeachemployeeby10%

incrementwhoarenoteligiblwforcommission.

a)updateempsetsal=sal+sal*10/100where

commisnull;

100)SELECTthoseemployeewhojoinedthe

companybefore31­dec­82whiletheirdept

locationisnewyorkorChicago. a)SELECTEMPNO,ENAME,HIREDATE,DNAME,LOC FROMEMP,DEPTWHERE (EMP.DEPTNO=DEPT.DEPTNO)AND

HIREDATE<'31­DEC­82'ANDDEPT.LOC

IN('CHICAGO','NEWYORK');

101)DISPLAYEMPLOYEE

NAME,JOB,DEPARTMENT,LOCATIONFORALLWHO

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

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.

4/24/2016

SqlQuerrys|AtoZ

a)

123)Displayemployeename,sal,commandwhose

netpayisgreaterthan

anyotherinthecompany?

a)

124)Displaynameofthoseemployeewhoare

goingtoretrie31­DEC­99.

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

charactersfromhiredate­last

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.

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?

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

Sub­ordinateto

BLAKE?

a)selectemp.enamefromemp,empewhere

emp.mgr=e.empnoand

e.ename='BLAKE';

155)Displaythosewhoareworkingasmanager

usingCO­relatesub­query?

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)

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)

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)

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.

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)

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:

findoutallemployeesnameandsalarywhoisworkinginSMITHdepartmentasmanager

plsgivequeryforthis

Unknown said Unknownsaid

SELECTENAME,SALFROMEMPWHEREENAME='SMITH'ANDJOB='MANAGER';

4/24/2016

SqlQuerrys|AtoZ

SpRaju said SpRajusaid

SELECTENAME,SALFROMEMPWHEREENAME='SMITH'ANDJOB='MANAGER';

selectename,salfromempwhereename='smith'andjob='manager';

Unknown said Unknownsaid

DisplayalltheemployeenamesinResearchandSales

Departmentwhoarehavingatleast1personreportingto

them

needsqlquerypleasehelpme

them needsqlquerypleasehelpme 3November2015at11:03 BilalAhmad said Plzhelpmeinthisquery

Plzhelpmeinthisquery

Displaynameoftheemployeeswho’snamestartswith‘a’andhas‘e’assecondlast

character.

Selectnamefromemployeewherenamelike'a%'and'%e_'

Thiscommenthasbeenremovedbytheauthor.

elifözer said elifözersaid

Thiscommenthasbeenremovedbytheauthor.

hiiineedahelpforthisquerry

querry:­

listalltheemployeeshavingthesamejobasemployeesinchicago

Selectemployee_ID,Job_IDfromemployeewhereJob_Locationlike'Chicago'

Querytodisplaydeptno,sum(max(sal))ofoveralldeptnoandcorespondingdname

Thiscommenthasbeenremovedbytheauthor.

AJITKUMAR said AJITKUMARsaid

writeaquerryforSMITHISCLERK

4/24/2016

SqlQuerrys|AtoZ

SANDEEP said SANDEEPsaid

Thiscommenthasbeenremovedbytheauthor.

SANDEEP said SANDEEPsaid

Thiscommenthasbeenremovedbytheauthor.

PostaComment

Enter your comment

Enter your comment
Enter your comment Commentas: GoogleAccoun Publish Preview

Commentas: GoogleAccoun

Publish Preview
Publish
Preview

Linkstothispost

Subscribeto:PostComments(Atom)

2010­Copyright©AtoZAllrightsreserved.

DesignedbyTemplatelite.ConvertedToBloggerTemplatebyAnshul.