You are on page 1of 9

-

Using ere Presi in d SElECT quy:


Use exp. in projectien Select rll,name, mi.m?, m3

(nf n2tm3) as Total fm! 4n24


mS)/3 as 'Avg nm sthude

Tol/ 3 Nod valid


Use exp in selection
display ctudest doda for oll gtudests
to
uho sto red avg manlcs>40
SELECT roll, name [ml,m2, ms} , m 1 t m2 t m aas
t ot l m i t m2 + m93 aAvg

RON Studuent
WHERE (mI + m+ n5)/3> D
OCDER BY Co Iname/s, expreiion /S, Column- Aias *

h n e resut of queny in lendiny or desterdin


Ord specihied lot erp/alik.
SELECT *|ollist fKOM -He_ ham & wHEREJntoup
By.1 CHAvIN-) 0 KDER 5Y <tlname/expplias >
LASC/DESCc]
LIMT ows
Traple
SELECt PROH Studed OKDE R BY noy
SELECr xeaH Studend tEbER RY name DESC
)SELEC FeOH Shudend unpt ty Mone, City
SGLEC ¥Ron heleut be R 5Y rame.city DESC

SELE CT rDll,n ame FROM Studeut orden by city


SELECT oll, ml m, m3mitmztm3 cu totd i CoM
studen oder by tetal
)SECECT rolln1, m2, m3, m!m2 tmS a tot
FRON Stude ov den by o ll, m+m2t m3 DESC
LIMITTo restrict no.
t rowsin odpuf.
StLECTT rom 3ude UMIT 10
Sau finction A Hodule=> To pertormn speribic

int add (intx, int y)i


TnC.
wite on Ce e many t mes

Prede Hinad tunctjons ingle -Rouo fnctiong


-Nulhiple - Roo funetions

single Roo
(Velue unction ofP
ingk Value

Mulhiple
Nalues HolHi
(Rouss Kow
Functien Sinyle valu4

unction ypes
- Anthmehic: herks teth numeruc. doda values. Ex. ABS,
SiGN, ROUND,TRUNC , CEIL FLODR,
MNDSIN, (OS, TAN,

Pow HOD,-.
ohanaekrr data. tx. ontaf l
-S tring Weres with
Couse le th,lcos e,ltim,rt
sL,S7s fMmIpod,Tpad aubsmjdr rev{se -tc
28
Dctte Works en Pate 4 Time fal vaue

-No.Curdate, DATE(d),TINE|d
ADDDATE (d, INTE RVAL vodke unit), DAY,
ONTHYEAK, ----ete.
Amit So red 87. marles.
Sumit scored48/ mor ks.
SECECT Aee, con Cot Iname, 'sco reol, (mf+ m2+m3)/3
marcs. FRoN Sude
SELGCT UCAIe[ name)
from tud@f,
)sELFCT n id (Ami f
Kumr',1,4) => ret T
S -'Cmit
lengHh(s) => 8
14i m, rtrin,trim trin off spares tom leH/nolt /both
ends
length (rhim ($)) = => lenth ('amit') =>4

ABS (-189 ); => 87


Stlec
)select und (t23.) = = ) 123
Sclect leor (121.999);) 121
Selec Cei (121.bv) ==> 2z

)Se lect PIU,==) 3142


Se lec - roll, nane,m) m, I4 mz4ms/3,2 as

Aron studod uvmad

DATE
sELECt NOW D,
display
Friday 01, Sept 2022.-Wonk to
Date Fermat ldedevalue.,md)
fmt a-> Sun,fon Tue
7b->Jan,ab,-.
-m modh 00-12
. N-Januny,febuauy
d/ye> ay vaubut ol to 31/1 3
P-AM/prt
h Howy .i Mnudes S Sebnds
Y.D day wih suthin Ist, 2nd, Srd,-.
y ->yea e y ->yeor to2]
DATEDIFF (dt da)
Mult Row hunctien
H9a negoation
Count
8um

-mln
mo

He- Wark
Prachee SELECT Command
Cxprexm tuntto 9ules
1elo2 30
null valuus ont not 4ed in exp- =) nu
To were with null values spl openator is
9iven n SeL > 1S alo we 1S NOT
SeceCt from studene uhtne clonamt 1S NUU
Converting null to value TFNULL /nullvalla. ,to.volv
select 1 FNULL (null, too);
Select if null mI,0) + Hnull (m2,0 )as ' Tlal' {rom
hudend
Seleet coUndLifnyll (m3,0) from Shudent
Conwer tig null to vaue JVL (nal. Valut tevalue
t-selecf NVL (nu ro) from dual
Selecf rl (mi0) + nvl (m2,0) ay' T0TAL' fom Srtudent
Selec count (nvl (m2,0)) yom
Studeut
clakmater Student masten
TolLno int PK
clas tode Int Pk hame VC (so) NN
clas nan VC(30) N gender C m
bdate DATE
city Ve(30)
elak to de INT FR Rebunas
clo mster

Colunn alias is not used in wshou olaus

-Wocg to display troll, nane age b huded -


select roll, rane Hoor (dated ff (nouw(), bdafe)
/36 08 0ga fom stde-dhngsteh
Nog to diplay shudeut data y Stude-ds uhese
1 i n betuven 24 30p
Select* from sthude-tmosten whnt dorkdi (nowU,
bdade)/3&s >24 ond dated iFE/nous (). bdode))
365 30 6des
Same il <e 30 grder by age

OR
Select roll,hane tlocr (daediff( nouw), bdate)/36r
poo m \
a tom studentmater
a
2m
ukaht dabcdith (new0, bdade)4
Retueen 24 80 000

0ader6y
omur?
0

(v mwop

TEA SREAK -A1 S'30Pa

9 to display roll,none. 9under city for


all studets om kelkata
selecf rll, nomd, Gude om tudesdmagt
uuhuns city kolkata
to display voll , name gunden Crhy hr
Wag
all shuderds tro kolkod, e hi , Natda , Jhasi,
Select rellkhane, genden ,city trDm Studentmoster
Luhu city lik kolkafa' or city like 'Pune' or tity lie Deki
Joq
SWog tro Aiplay st t puco-ds hete naune

knds wih ledHer. S.


selecthamt trom studpuchnasfen weu. non like'sz;

Select roll,nard.nden,eity hom 9hudentmosteh


ukanu
city Celbate cr
city ='Delhr"
Select rollCmt 9vdor, ity yom 3tudent moutt
tuhgne
cihy in 'calEata',Delhi, "R')
jst studonds ue nand he penafo
Endy t h leter
Openatoos!
Select ha tren Studentmoste
-Singhe chanacen
Luhon hCnL li
7T 7-Set ohantHe

6-ist ostudendg = Pinopal

O INS Joirin two Or more, tables on the bosis of


Commem columnattalbea toetth data.from mul Fipie
Clamasten Shyded mas te table
-clascod e roll
ham
bdott roll name clanoc
- tlhy
qan der 4 Am FECSE
Canom chtode 22 An rh FECE
Child rdlotionsuP
3
Tyfes tJ0ZNS:
-
(ross Jein ((antajan Yrnduct)
mkn uht m is no o
fDtus otirst table 4nis the ne ofnuS tmm
9eCOndtoble
Innan Jrin Retunh doda tor modhina outeu a

Dufer Ten;-Reuruns doda formatehing Crurfeua,


oleng wth e exesdot trom &Horn /boh tabla
le Jein
r i g t outei jnn

Perth

-Norual THn
1Hs Hupe mihjo1n
no d +o speciby Crutenua
H ullGth toble on the boe 0ommen, Colum
haunls Anengcudles

UsING (tolumnfAro/S)
table is jeinad uith I'selt
Self jetn: hon

t9 Jein bojed on =in criteia


Nen-Eap Tein bouesl on o-thet an egalty(=)
CrO joi n
-e Select tem cloute Sfudevd mouHerz
select- roll, rome, clownant fom 9hudatmalten Cres jetn
clalsmoute
To oveicd tolumn nam. contlicts ouneng d .Ables
ponticipating in join we can uie
with tolLnamt hot is tule .nami
hoble-hounl alers
hamt Claxmasieh-class
tol-name g-stuclentmalHth.
eo shudholen.roll, clawaslen-tlava dutmaken, dovk meske
OrabHe aliases in SaL ttajtmdAUHenpoyuy fo or otble
Select a.roll, a nam, b.claißndntom
ShudortmosBer a, clastmurbn b
9elect a roll,a-ro b.ClaMnamtom Stud
,

etnaet aj a,claumaen
Qsb
2-nner Jein: select col hiot fren foble 1[one)
select a roll, b-dosnamt. trom Shudetmat a Tinne]join cla,
Natural Tein 29No need to spechy j crikerua. Ona-tlautede
b
einnghloeh plae en comon tolumn name/s. cl68ode

tfom s tudotrnos tUz o


3elect a.roll, a.nameb claadnant
hadunal jein doumato b
a-gender, Heor (dafeditH (nowU,
b)
Sclen a fll, o.nam

Her o tnner
agR,b.clas3 nanm Dm 3hudontmas
/36
a-claM code b Clasxede rdex
eloamaaHth. b On
Jein
Bb.Cloknade, q rollnD,
by

Felh Ha dota fromn muliple table

You might also like