0% found this document useful (0 votes)
7 views11 pages

Idassignment 3

The document outlines a series of SQL queries and expressions related to various database operations, including selection, updating, and deletion of records from instructor and course tables. It covers a range of functionalities such as calculating averages, totals, and updating salaries based on specific conditions. Additionally, it includes examples of string manipulation and date formatting in SQL.

Uploaded by

reeth66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Idassignment 3

The document outlines a series of SQL queries and expressions related to various database operations, including selection, updating, and deletion of records from instructor and course tables. It covers a range of functionalities such as calculating averages, totals, and updating salaries based on specific conditions. Additionally, it includes examples of string manipulation and date formatting in SQL.

Uploaded by

reeth66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

AssiGNMENT- 3:

1) Write the sQL Expsessions fore the Foloing queriee


usina suitable sÍL op enatos
Ced to ok CoUsse

y Display the Couvse -ide T:tleg and


ouwse -id
that otcered tn any of he depard ents
namely :
Physics Music firance and Biology
Covsse_id,Title, Csedite
SELECT
fROM Cousse
INC Physics', Music', Bioloay
WHERE Dept- name
Cfinonce

Olp: 6 rows selecte d.


whose hame
secosds of the in strvc toss
) Display get sala
nose than

start s with (K and who


6s00 O.
SELECT
Fkory InStructos
)=6SO00.
N ane
LiKE K°% AND Salay
WHER
Name Dept-Nome Salag
Olp: 4556S Kotz Comp Sci
Elec.
qs 34 S Kim

salary cnd ne t
) Display name,d past ment, q 30ss 20°/o HRA
with 10S/o DA,
SaUlary Ok i nst uc toss +DA + HRA.
-Cgvose salany = salay -IT)
net salary=gross salary

SE LECT Name Dept- nane


"Grsoss Salary
1-os* Sa lony t O-2*Salary "G
salag
1.08* Sal ay t o-2* Salory t Salay -o3
"Net- Salay fROM Instructor
Olp: 12 rous selec ted and Net-Salay and Gsoss. Salary
columns added
the Lnstructoss with salany
(a yDisplo recosds ob
GOO0O to 2000O
range
SELECT
fROM Instructos
BE TWEEN 60000 ANO Oo00,
WHERE
Solory
selec te d
4he Instructosc havig the
the yecosds ob
(e) Display ¿h theiy ane
second detter

+ROM lostrUcto
L7KElo:
WHERS Nme

ol
NOne
Dept Name Salang
Sci.
Ssinî vOsan Conp T200O

Csick B iolog
6766 qz0OO.
8382l Bsad t
Comp Sci.

inst ruc toss ot op. Sci,


ob the
($) Dieplay the nmes
os der ot theix salg
Depardment in the des cending
SELECT Name)
Lnstructox
salang
FROM
WHERE Dept-Dome comp
ORDER salang pesc:

Olp: Nane salay


Brandt q200O

Katz
S ini VOsan
with a
(g) Update all secovde s Instruc to table
sal ny hi ue o6 Iso.
UPDATE lostrvc to s
SET Salory = Salaryt 0-15* alay
row0S updeted.
ot 3 o os
) Update the secoxdc wit a saloy hike

Comp. Sei. Dept. instruc toss fhowing colay Les thas 7CoO0.
UPDATE Ins tructos
SeT
Salay Salary t003 * Salory
WHERE <700 oo AND Dept_Nome = Comp. Sci

up dated.
Corp-Sci. Dept_Name.
Solay Colwmn Upcated bor
in ctructos.
) Dispay the annval salay ob each
Solary*la
SELECT Name,
FROM Instructos
selected.
Olp 2
having t:tle Ghome Desig
the title ot the couTSe
)Update
to Game Theosy'.
UPDA TE Couse
Title = Gane Theosy
WHERE Title = Deaign'
lp: 1 row updated.
Histosy depantmet
k) Delete the instruc tos

DELE TE FROM Instryctos

WHERE ept Nane = History


Olp: 2 rows deleted
coUTSeR
secosde ob the
the cOUSSe
) DELE TE
cOUTSe-id starting with <BIO

FROM coURSE
DELE TE
WHERE CourSe- id
LiKE BIO lo
Olp: 3 rows delet ed.
2) Weite the s9L Expzessions fox the folousing querieg Using
suitosle SOL aagse qate function.
o6 instruetos os Physies dept.
) Display the Avg-solog
AVG (SolayAVG. sALARY"
SELECT
FROM (nstructo
WHERE Dept- name Physics:
olp AVG. s ALA RY
1046SO Paid to
b) Display the Dept-name
cund Average saloy
depatett
instructos oh each
SELECT Dept-nae ovg (Salany)
Instrvctos
FROM
Gsoup by bept Nome;
select ed.
Olp Grows
Instructor
Depatment of the
c) Display the l, Nane &
the bighest s a l y
drawing
Dept-Name
5ELECT TD, Non e
Instructos FROM
FROM
CSE LECT
MAX CSalary
WHER Salay >
lostructoo
Dept Name
Nome
E instein Physics
2 2.222
availabh in Comp Sci. Dert!
instauctore
the no. dk
d)Display
lnstrctoss
SELECT COUNT *) AS Num
F ROM lnstructos
Sci. '
WHE RE Dept - Nane Comp
Num lnstrutoss

csedits of a l coUsces obkeed i


e) Display the total
Comp- Sci. Deportment.
Cxedits
SELECT SUM CCedits) As Total-
Cousse
fROM
comp.Sci
WHERE Dept -Name =
Cuedits
Olp: Total

instructoss ond total calany drawn by


5) Dis play the no- o7 Sci. de partnerte.
Þhysics and Cormp- Nom-Instruetoss,
CoUNT *) As
SELE CT Dept Nane
sQLoy
sUM CSalory ) As Total-
feom lnstructox
INC'Physics ', 'Comp. Sci.')
wHERE ept- Name
GROUP BY Dept - Namej

Ofp: Numlnstructoss Total-Salany


Dept - Nene
209300
LOS800
Physics 1
Comp -Sci.

cb Comp Sci and Biology


9) Display the tot al cecits toble.
deportmen ts from CO Us Se
SUM (Csedi ts) As To tal -Csditg
SeLECT Dept -name,
fROM Cousse
Biolog y')
Dept ncmne \N C'omp- Sci.',
GROUP BY Dept -Namej
Dept Nane Total Credits

Comp- Sei.
wise gt values.
totall budqt
h) Dispay bu:lding
SELECT Boildung, SOM CB vdget ) AS Total- Bydgt
FROM Department
GROUP
ey Boilding :
To tal-Budqet
Boildin
140o00
Paint
1600 0o
Watson

Taylos 200O0

Packad
departments.
os c ob each
of inctruct
i) Disploy h no
coUNT C*) AS
Numnstrutoss

s ELECT Dept-Name,

FRoM Instruc toxe


By Dept Nane
GiROUP
selected
Olp o7 each dept.
ihstruc to8
no. ob
3) Disploy -he
to Co co.
Sote d in high ASNyM lnstructss
CoUNT C*)
SELEC T Dept- Nome,

FROM lostructos
GROUP BY Dept-Nne

tos s De SC -
Num_lastuc
ORDER BY
instuc to5 s
NuM
pEPT.Nane

Phy sics 2
Comp- Sei.

7 rows s elected Sen wise

u) Display the no
coUNT ( ) As
SELE CT Senegt ,

FROM Couse
GROUp BY seme te

the nome ob deportmets hawing no-


ob
L) Dicploy Less than .
ínstructsoxs

SELECT Dept-nane
FROM Instructo
coUnNTC*) K 2
GROUP BY Dept -nane Having
Olp Dept -Nome
ELec. E ng
Biology
Comp. Sci.
Music.

ot each dept. having 2 ox


m) List the no . ok inctructoss
th as 2 i0structoSS except. Finan ce dept,
ot theis num ber
Sorr ted in high tolow osder
Nomlnstructoss
SELECt Dept-n ame, Co UNT C ) As
FROM lnstructos
Dept -none Finonce
GROUP By Deptnone

Howing GouNT C)>2


ORDER BY Num_astUctoss DES

Noslostvetog
Dept Name
2
Co mp- Sci.
2
Physics
m) Dirplay the be pt -name that hcs e d to tal
salony mose tha S ooO

SELECT
Dept nnme
FROM lns truc tos
GRO UP By Dept -name

touing
Dept ~Name
sUMCSal ary > soo O0

Phy sics
Corp- Sci
Elec - ng rows selected
o) Display the total budget fos the bulding built
by watson
seLeCT SUMCBudget As TotaBudget
PROM Department
Buildinalwtcon'; Olp To tal Budget
1600 o
P) Display highe t salary ob the nstructos ot
the
Comp: Sci. pep antmet.
SELEC T MAXCSalay) AS HighutSalany
FROM Vnstrcto
Dept Naye
'Comp -ci.
WHER¬

Olp? HIGAEST_SALA RY
|oS 8 O0.

fos the bolo wing 2veies


Expressions
3)Write the sQL 6wntian .
USin a suitabe s cala
Letten bengcapital
noue with fisst
yoUs
)Displo the ent u d name
t 9 o wer cage.

whee
chinmayi1)
CUPPER CSOBsTR C'
SELECT CoNCAT
'chinmaui, ) ) )AS Name
LoER CsUBSTR C
wit Capita- Fisst - Lettez
fROM DUAL Fisst - Letter
Nome- wih Capital

Chinmcuyi.otees

and- 6th ch8


b) Displag
ceLECT s UBSTRC c i n m a y i j 2 ) s) As Substring-2-to_6
FROM DUAL
Olp. sOBST RING 2 to-b
hinOa
Uni veraity name
c) find the length youx

SELECT LeNGT N C1SIKSH OANUSHANDHAN) AS Univeit


-Nome e
FROM DOAL;
Univensi ty - NANAME-Len
n omeg
Instructor
d) Display all he
in Upper cose
(UPPeRCSOBSTRCN
ome 1 ))
SELECT CoNCAT
lostuctasNome
CsuSTR CNm 2)) ) A S
LowE R

fROM lnstcòs
olp

Soiniasn

Chold
rowS
celec tad.
each instruc tox s
e)Lis t the depatmen t name ob
3 lette code.
Departmet Coce
DeptName 1 3) As
LCT SUBsTRC
FROM IastrucEos
Department Code
o/p

Fin
Mus
selected
o b eachzostuctos

the month ols the joining Month


s) Display t MM') As Toinjng
SELECT TO-CHAR CUoing D ate
FROM lnstructo
selected
instructos in
joining ob each
9) Dis play the date
fosmadt.

CDate-ob- Jo înig
SELE CT Name, DA TE FORMAT
SAS Joinin¡ Date
FRoM lstructos
Olp: Osows s elected
Display the ex peuen ce o7 each nstruc tos in t e n
ob months
SELEcT
NameTIME S TA MP DiF CMoNTH, Date_ot
oining CUR DATEC) ) AS Experience -Mon the
feOM Instruc tos
p- 10 s elected.
(i) Display the expeence tn tem ol yeone &nmonths.
SELEC T Nane,
FLOOR CMONTHS_BeTJEEN (SySDATe, Teining_Dade)y
2)||yeans|
MOD C MONTHS ETOEENCsySDTE oining-Date)
12)| months AS Exp erien ce
FRO Instuctos
Olp- |0 sOws selec ted

G) Display the day ob joining of each instroctes.


SeLE cT Nane
To-CHA e C Joining Dae (Deg'As Day-0s_ Sening
FROM lnstrvctox
selected.
the olate cosses pond in g to IS cdays attez
(e) Display
today?s date A ter Today
SELECT Sys DA TE AS DATE -Is- Days
FROM bUAL
Olp DA IE-IS Doys AGter-Today
O4 -APR- 2S
94904.24348 trun cated upto 2 digite
Desplay the valve
bter decinal pt
pt. TruncatedYALUE

2724& ) As
Ca4204-
TRUNC
Se LEC T
FRom puAL

Truneted- VALVE

542
exps easion
the value
ob the
AS regultrRoM DUAL,
) Pisplay
Olp? resolt:

1 3 4 2 | 4 4 3 3

G4643)2
Find ÖUt the
S9t

Squau-Root
ROM DOAL
n) G4312) AS
SQRT C64
SELEC T
S 9 u a e - Root
olp:
2 5 4 2 . S o l I 3

IIERn
lowen cae
HELLO

) Display the string loser


column beading
with a ) AS towercae
C HELLO ITER
SELEcT
LowER

FROM DUAL

Lo we
Olp?
hello :te

You might also like