Вы находитесь на странице: 1из 8

SCL CuLS1lCn AL8(MuL1lSCl1 S?

S1LMS)

1 LlsL all Lhe employees who have aL leasL one person reporLlng Lo Lhem
2 LlsL Lhe employee deLalls lf and only lf more Lhan 10 employees are presenL ln deparLmenL no 10
3 LlsL Lhe name of Lhe employees wlLh Lhelr lmmedlaLe hlgher auLhorlLy
4 LlsL all Lhe employees who do noL manage any one
3 LlsL Lhe employee deLalls whose salary ls greaLer Lhan Lhe lowesL salary of an employee belonglng Lo depLno 20
6 LlsL Lhe deLalls of Lhe employee earnlng more Lhan Lhe hlghesL pald manager
7 LlsL Lhe hlghesL salary pald for each [ob
8 llnd Lhe mosL recenLly hlred employee ln each deparLmenL
9 ln whlch year dld mosL people [oln Lhe company? ulsplay Lhe year and Lhe number of employees
10 Whlch deparLmenL has Lhe hlghesL annual remuneraLlon blll?
11 WrlLe a query Lo dlsplay a '*' agalnsL Lhe row of Lhe mosL recenLly hlred employee
12 WrlLe a correlaLed subquery Lo llsL ouL Lhe employees who earn more Lhan Lhe average salary of Lhelr deparLmenL
13 llnd Lhe nLh maxlmum salary
14 SelecL Lhe dupllcaLe records (8ecords whlch are lnserLed LhaL already exlsL) ln Lhe LM Lable
13 WrlLe a query Lo llsL Lhe lengLh of servlce of Lhe employees (of Lhe form n years and m monLhs)
16 llnd ouL Lhe selllng cosL average for packages developed ln Cracle
17 ulsplay Lhe names ages and experlence of all programmers
18 ulsplay Lhe names of Lhose who have done Lhe CuCA course
19 WhaL ls Lhe hlghesL number of coples sold by a package?
20 ulsplay Lhe names and daLe of blrLh of all programmers born ln Aprll
21 ulsplay Lhe lowesL course fee
22 Pow many programmers have done Lhe uCA course
23 Pow much revenue has been earned Lhrough Lhe sale of packages developed ln C
24 ulsplay Lhe deLalls of sofLware developed by 8akesh
23 Pow many programmers sLudled aL enLafour
26 ulsplay Lhe deLalls of packages whose sales crossed Lhe 3000 mark
27 llnd ouL Lhe number of coples whlch should be sold ln order Lo recover Lhe developmenL cosL of each package
28 ulsplay Lhe deLalls of packages for whlch Lhe developmenL cosL has been recovered
29 WhaL ls Lhe prlce of cosLllesL sofLware developed ln v8?
30 Pow many packages were developed ln Cracle ?
31 Pow many programmers sLudled aL 8ACA1Pl?
32 Pow many programmers pald 10000 Lo 13000 for Lhe course?
33 WhaL ls Lhe average course fee?
34 ulsplay Lhe deLalls of programmers knowlng C
33 Pow many programmers know elLher C or ascal?
36 Pow many programmers don'L know C and C++?
37 Pow old ls Lhe oldesL male programmer?
38 WhaL ls Lhe average age of female programmers?
39 CalculaLe Lhe experlence ln years for each programmer and dlsplay along wlLh
Lhelr names ln descendlng order
40 Who are Lhe programmers who celebraLe Lhelr blrLhdays durlng Lhe currenL
monLh?
41 Pow many female programmers are Lhere?
42 WhaL are Lhe languages known by Lhe male programmers?
43 WhaL ls Lhe average salary?
44 Pow many people draw 3000 Lo 7300?
43 ulsplay Lhe deLalls of Lhose who don'L know C C++ or ascal
46 ulsplay Lhe cosLllesL package developed by each programmer
47 roduce Lhe followlng ouLpuL for all Lhe male programmers
rogrammer Mr Arvlnd has 13 years of experlence

II . SCHEMA :
Table : DEPT
BEPTN0 (N0T N0LL , N0NBER()), BNANE (vARCBAR()), L0C (vARCBAR()

Table : EMP
ENPN0 (N0T N0LL , N0NBER()), ENANE (vARCBAR()), }0B (vARCBAR(9)), NuR (N0NBER()),
BIREBATE (BATE), SAL (N0NBER(,)), C0NN (N0NBER(,)), BEPTN0 (N0NBER())

MCR is tbe empno of tbe employee wbom tbe employee reports to. DEPTNU

1 LlsL all Lhe employees who have aL leasL one person reporLlng Lo Lhem
2 LlsL Lhe employee deLalls lf and only lf more Lhan 10 employees are presenL ln deparLmenL no 10
3 LlsL Lhe name of Lhe employees wlLh Lhelr lmmedlaLe hlgher auLhorlLy
4 LlsL all Lhe employees who do noL manage any one
3 LlsL Lhe employee deLalls whose salary ls greaLer Lhan Lhe lowesL salary of an employee belonglng Lo depLno 20
6 LlsL Lhe deLalls of Lhe employee earnlng more Lhan Lhe hlghesL pald manager
7 LlsL Lhe hlghesL salary pald for each [ob
8 llnd Lhe mosL recenLly hlred employee ln each deparLmenL
9 ln whlch year dld mosL people [oln Lhe company? ulsplay Lhe year and Lhe number of employees
10 Whlch deparLmenL has Lhe hlghesL annual remuneraLlon blll?
11 WrlLe a query Lo dlsplay a '*' agalnsL Lhe row of Lhe mosL recenLly hlred employee
12 WrlLe a correlaLed subquery Lo llsL ouL Lhe employees who earn more Lhan Lhe average salary of Lhelr deparLmenL
13 llnd Lhe nLh maxlmum salary
14 SelecL Lhe dupllcaLe records (8ecords whlch are lnserLed LhaL already exlsL) ln Lhe LM Lable
13 WrlLe a query Lo llsL Lhe lengLh of servlce of Lhe employees (of Lhe form n years and m monLhs)

.SELECT BISTINCT(A.ENANE) FR0N ENP A, ENP B WBERE A.ENPN0 = B.NuR; oi SELECT ENANE
FR0N ENP WBERE ENPN0 IN (SELECT NuR FR0N ENP);
. SELECT * FR0N ENP WBERE BEPTN0 IN (SELECT BEPTN0 FR0N ENP uR00P BY BEPTN0 BAvINu
C00NT(ENPN0)> ANB BEPTN0=);
. SELECT A.ENANE ENPL0YEE, B.ENANE REP0RTS T0 FR0N ENP A, ENP B WBERE
A.NuR=B.ENPN0;
. SELECT * FR0N ENP WBERE ENPN0 IN ( SELECT ENPN0 FR0N ENP NIN0S SELECT NuR FR0N
ENP);
. SELECT * FR0N ENP WBERE SAL > ( SELECT NIN(SAL) FR0N ENP uR00P BY BEPTN0 BAvINu
BEPTN0=);
. SELECT * FR0N ENP WBERE SAL > ( SELECT NAX(SAL) FR0N ENP uR00P BY }0B BAvINu }0B =
NANAuER );
. SELECT }0B, NAX(SAL) FR0N ENP uR00P BY }0B;
8. SELECT * FR0N ENP WBERE (BEPTN0, BIREBATE) IN (SELECT BEPTN0, NAX(BIREBATE) FR0N
ENP uR00P BY BEPTN0);
9. SELECT T0CBAR(BIREBATE,YYYY) YEAR, C00NT(ENPN0) N0. 0F ENPL0YEES FR0N ENP
uR00P BY T0CBAR(BIREBATE,YYYY) BAvINu C00NT(ENPN0) = (SELECT NAX(C00NT(ENPN0))
FR0N ENP uR00P T0CBAR(BIREBATE,YYYY));
. SELECT BEPTN0, LPAB(S0N(*(SAL+NvL(C0NN,))),) C0NPENSATI0N FR0N ENP uR00P
BY BEPTN0 BAvINu S0N( *(SAL+NvL(C0NN,))) = (SELECT NAX(S0N(*(SAL+NvL(C0NN,))))
FR0N ENP uR00P BY BEPTN0);
. SELECT ENANE, BIREBATE, LPAB(*,8) RECENTLY BIREB FR0N ENP WBERE BIREBATE =
(SELECT NAX(BIREBATE) FR0N ENP) 0NI0N SELECT ENANE NANE, BIREBATE, LPAB( ,)
RECENTLY BIREB FR0N ENP WBERE BIREBATE! = (SELECT NAX(BIREBATE) FR0N ENP);
. SELECT ENANE,SAL FR0N ENP E WBERE SAL > (SELECT Avu(SAL) FR0N ENP F WBERE E.BEPTN0
= F.BEPTN0);
. SELECT ENANE, SAL FR0N ENP A WBERE &N =(SELECT C00NT (BISTINCT(SAL)) FR0N ENP B
WBERE A.SAL<=B.SAL);
. SELECT * FR0N ENP A WBERE A.ENPN0 IN (SELECT ENPN0 FR0N ENP uR00P BY ENPN0
BAvINu C00NT(ENPN0)>) ANB A.R0WIB!=NIN (R0WIB));
. SELECT ENANE ENPL0YEE,T0CBAR(TR0NC(N0NTBSBETWEEN(SYSBATE,BIREBATE)))||
YEARS || T0CBAR(TR0NC(N0B(N0NTBSBETWEEN (SYSBATE, BIREBATE),)))|| N0NTBS
LENuTB 0F SERvICE FR0N ENP;





16 llnd ouL Lhe selllng cosL average for packages developed ln Cracle
17 ulsplay Lhe names ages and experlence of all programmers
18 ulsplay Lhe names of Lhose who have done Lhe CuCA course
19 WhaL ls Lhe hlghesL number of coples sold by a package?
20 ulsplay Lhe names and daLe of blrLh of all programmers born ln Aprll
21 ulsplay Lhe lowesL course fee
22 Pow many programmers have done Lhe uCA course
23 Pow much revenue has been earned Lhrough Lhe sale of packages developed ln C
24 ulsplay Lhe deLalls of sofLware developed by 8akesh
23 Pow many programmers sLudled aL enLafour
26 ulsplay Lhe deLalls of packages whose sales crossed Lhe 3000 mark
27 llnd ouL Lhe number of coples whlch should be sold ln order Lo recover Lhe developmenL cosL of each package
28 ulsplay Lhe deLalls of packages for whlch Lhe developmenL cosL has been recovered
29 WhaL ls Lhe prlce of cosLllesL sofLware developed ln v8?
30 Pow many packages were developed ln Cracle ?
31 Pow many programmers sLudled aL 8ACA1Pl?
32 Pow many programmers pald 10000 Lo 13000 for Lhe course? 1echnlcal ApLlLude CuesLlons


L?S
. SELECT Avu(SC0ST) FR0N S0FTWARE WBERE BEvIN = 0RACLE;

. SELECT PNANE,TR0NC(N0NTBSBETWEEN(SYSBATE,B0B)) AuE,
TR0NC(N0NTBSBETWEEN(SYSBATE,B0})) EXPERIENCE FR0N PR0uRANNER;

8. SELECT PNANE FR0N ST0BIES WBERE C00RSE = PuBCA;

9. SELECT NAX(S0LB) FR0N S0FTWARE;

. SELECT PNANE, B0B FR0N PR0uRANNER WBERE B0B LIKE %APR%;

. SELECT NIN(CC0ST) FR0N ST0BIES;

. SELECT C00NT(*) FR0N ST0BIES WBERE C00RSE = BCA;

. SELECT S0N(SC0ST*S0LB-BC0ST) FR0N S0FTWARE uR00P BY BEvIN BAvINu BEvIN = C;

. SELECT * FR0N S0FTWARE WBERE PNANE = RAKESB;

. SELECT * FR0N ST0BIES WBERE SPLACE = PENTAF00R;

. SELECT * FR0N S0FTWARE WBERE SC0ST*S0LB-BC0ST > ;

. SELECT CEIL(BC0STSC0ST) FR0N S0FTWARE;

8. SELECT * FR0N S0FTWARE WBERE SC0ST*S0LB >= BC0ST;

9. SELECT NAX(SC0ST) FR0N S0FTWARE uR00P BY BEvIN BAvINu BEvIN = vB;

. SELECT C00NT(*) FR0N S0FTWARE WBERE BEvIN = 0RACLE;

. SELECT C00NT(*) FR0N ST0BIES WBERE SPLACE = PRAuATBI;

. SELECT C00NT(*) FR0N ST0BIES WBERE CC0ST BETWEEN ANB ;

. SELECT Avu(CC0ST) FR0N ST0BIES;






I. SCHEMAS
Table : STUDIES
PNANE (vARCBAR), SPLACE (vARCBAR), C00RSE (vARCBAR), CC0ST (N0NBER)

Table : SUFTWARE
PNANE (vARCBAR), TITLE (vARCBAR), BEvIN (vARCBAR), SC0ST (N0NBER), BC0ST (N0NBER), S0LB
{NUMBER]

Table : PRUCRAMMER
PNANE (vARCBAR), B0B (BATE), B0} (BATE), SEX (CBAR), PR0F (vARCBAR), PR0F (vARCBAR), SAL
(N0NBER)

LECEND :
PNANE - Piogiammei Name, SPLACE - Stuuy Place, CC0ST - Couise Cost, BEvIN - Bevelopeu in, SC0ST -
Softwaie Cost, BC0ST - Bevelopment Cost, PR0F - Pioficiency


. What is the aveiage couise fee.
. Bisplay the uetails of piogiammeis knowing C.
. Bow many piogiammeis know eithei C oi Pascal.
. Bow many piogiammeis uon't know C anu C++.
. Bow olu is the oluest male piogiammei.
8. What is the aveiage age of female piogiammeis.
9. Calculate the expeiience in yeais foi each piogiammei anu uisplay along with
theii names in uescenuing oiuei.
. Who aie the piogiammeis who celebiate theii biithuays uuiing the cuiient
month.
. Bow many female piogiammeis aie theie.
. What aie the languages known by the male piogiammeis.
. What is the aveiage salaiy.
. Bow many people uiaw to .
. Bisplay the uetails of those who uon't know C, C++ oi Pascal.
. Bisplay the costliest package uevelopeu by each piogiammei.
. Piouuce the following output foi all the male piogiammeis
Piogiammei
Ni. Aivinu - has yeais of expeiience

. SELECT * FR0N PR0uRANNER WBERE PR0F = C 0R PR0F = C;
. SELECT * FR0N PR0uRANNER WBERE PR0F IN (C,PASCAL) 0R PR0F IN (C,PASCAL);
. SELECT * FR0N PR0uRANNER WBERE PR0F N0T IN (C,C++) ANB PR0F N0T IN (C,C++);
. SELECT TR0NC(NAX(N0NTBSBETWEEN(SYSBATE,B0B))) FR0N PR0uRANNER WBERE SEX = N;
8. SELECT TR0NC(Avu(N0NTBSBETWEEN(SYSBATE,B0B))) FR0N PR0uRANNER WBERE SEX = F;
9. SELECT PNANE, TR0NC(N0NTBSBETWEEN(SYSBATE,B0})) FR0N PR0uRANNER 0RBER BY PNANE
BESC;
. SELECT PNANE FR0N PR0uRANNER WBERE T0CBAR(B0B,N0N) = T0CBAR(SYSBATE,N0N);
. SELECT C00NT(*) FR0N PR0uRANNER WBERE SEX = F;
. SELECT BISTINCT(PR0F) FR0N PR0uRANNER WBERE SEX = N;
. SELECT Avu(SAL) FR0N PR0uRANNER;
. SELECT C00NT(*) FR0N PR0uRANNER WBERE SAL BETWEEN ANB ;
. SELECT * FR0N PR0uRANNER WBERE PR0F N0T IN (C,C++,PASCAL) ANB PR0F N0T IN
(C,C++,PASCAL);
. SELECT PNANE,TITLE,SC0ST FR0N S0FTWARE WBERE SC0ST IN (SELECT NAX(SC0ST) FR0N S0FTWARE
uR00P BY PNANE);
.SELECT Ni. || PNANE || - has || TR0NC(N0NTBSBETWEEN(SYSBATE,B0})) || yeais of expeiience
"Piogiammei" FR0N PR0uRANNER WBERE SEX = N 0NI0N SELECT Ns. ||PNANE|| - has || TR0NC
(N0NTBSBETWEEN (SYSBATE,B0})) || yeais of expeiience "Piogiammei" FR0N PR0uRANNER WBERE
SEX = F;


;D
. Which uate function is useu to finu the uiffeience between two uates.
N0NTBSBETWEEN

. Why uoes the following commanu give a compilation eiioi.
BR0P TABLE &TABLENANE;
vaiiable names shoulu stait with an alphabet. Beie the table name staits with an & symbol.

. What is the auvantage of specifying WITB uRANT 0PTI0N in the uRANT commanu.
The piivilege ieceivei can fuithei giant the piivileges heshe has obtaineu fiom the ownei to any
othei usei.

. What is the use of the BR0P option in the ALTER TABLE commanu.
It is useu to uiop constiaints specifieu on the table.

. What is the value of 'comm' anu 'sal' aftei executing the following queiy if the initial value of 'sal' is
.
0PBATE ENP SET SAL = SAL + , C0NN = SAL*.; sal = , comm =

. What is the use of BESC in SQL.
BESC has two puiposes. It is useu to uesciibe a schema as well as to ietiieve iows fiom table in
uescenuing oiuei.
Explanation : The queiy SELECT * FR0N ENP 0RBER BY ENANE BESC will uisplay the output soiteu on
ENANE in uescenuing oiuei.

. What is the use of CASCABE C0NSTRAINTS.
When this clause is useu with the BR0P commanu, a paient table can be uioppeu even when a chilu
table exists.

. Which function is useu to finu the laigest integei less than oi equal to a specific value.
FL00R

8. What is the output of the following queiy.
SELECT TR0NC(.8,-) FR0N B0AL;


9. Which system table contains infoimation on constiaints on all the tables cieateu.
0SERC0NSTRAINTS
. TR0NCATE TABLE ENP; BELETE FR0N ENP; Will the outputs of the above two commanus uiffei.
Both will iesult in ueleting all the iows in the table ENP.

. What is the uiffeience between TR0NCATE anu BELETE commanus.
TR0NCATE is a BBL commanu wheieas BELETE is a BNL commanu. Bence BELETE opeiation can be
iolleu back, but TR0NCATE opeiation cannot be iolleu back. WBERE clause can be useu with BELETE
anu not with TR0NCATE.

. What commanu is useu to cieate a table by copying the stiuctuie of anothei table.
CREATE TABLE .. AS SELECT commanu
Explanation : To copy only the stiuctuie, the WBERE clause of the SELECT commanu shoulu contain a
FALSE statement as in the following.
CREATE TABLE NEWTABLE AS SELECT * FR0N EXISTINuTABLE WBERE =;
If the WBERE conuition is tiue, then all the iows oi iows satisfying the conuition will be copieu to the
new table.

. What will be the output of the following queiy.
SELECT REPLACE(TRANSLATE(LTRIN(RTRIN(!! ATBEN !!,!), !), AN, **),*,TR00BLE) FR0N
B0AL;
TR00BLETBETR00BLE

. What will be the output of the following queiy.
SELECT BEC0BE(TRANSLATE(A,89,), ,YES, N0 );
N0.
Explanation : The queiy checks whethei a given stiing is a numeiical uigit.

. What uoes the following queiy uo.
SELECT SAL + NvL(C0NN,) FR0N ENP;
This uisplays the total salaiy of all employees. The null values in the commission column will be
ieplaceu by anu auueu to salaiy.

. Which is the subset of SQL commanus useu to manipulate 0iacle Batabase stiuctuies, incluuing
tables.
Bata Befinition Language (BBL)

. What opeiatoi peifoims pattein matching.
LIKE opeiatoi

8. What opeiatoi tests column foi the absence of uata.
IS N0LL opeiatoi

9. Which commanu executes the contents of a specifieu file.
START <filename> oi <filename>

. What is the paiametei substitution symbol useu with INSERT INT0 commanu.
&

. Which commanu uisplays the SQL commanu in the SQL buffei, anu then executes it.
R0N

. What aie the wilucaius useu foi pattein matching.
foi single chaiactei substitution anu % foi multi-chaiactei substitution

. State tiue oi false. EXISTS, S0NE, ANY aie opeiatois in SQL.
Tiue

. State tiue oi false. !=, <>, = all uenote the same opeiation.
Tiue

. What aie the piivileges that can be gianteu on a table by a usei to otheis.
Inseit, upuate, uelete, select, iefeiences, inuex, execute, altei, all

. What commanu is useu to get back the piivileges offeieu by the uRANT commanu.
REv0KE

. Which system tables contain infoimation on piivileges gianteu anu piivileges