fnd the dyfeenee betw een totat no uty enme
n the tabe and no o< distndt aty en mes i w hetabl
Sol) Selet CouNT(CITY) - (oUNT{DISTINCT CTY) A
diference
CRo STAtION
( Quet the two utre 'a srA TION wit t
Orget CITy name, well a they eopectt ve
Ik morethan one nallet or argest
larger
cy. choose tte ane that comes dldered
t ushen c\durg
Setect scity, ngth ls aty)
FRom STATION a s
y ength (TY) ASe, ciTYASG
ORDER
LIMIT 1
UNION ALL
(
(sciT)
SELECT scity, sng th
FROM StATION s. aTY Asc
cITY) bESC
ORDER 8y LENqTH
UMIT 1,
9 Get fis4
character in a cmng
SELECT LEPT(CIT Y, 1) As fosthor
ML.
PloM stAlon
lengh horater
Arth
SUBsTANG (ciTY,4.
(CITY, 1) A
4,2)
M SEEt SUBSTRNG
PROM STATI ON
Staut
pes t
Snduling
character ih aShing.
aet the (at
SELECT RIqHI(CY,1) As lotchar
fROM Statten'
Similuy subsang fnchton
PR) epents 4 pattern danor by Julia in R Rouer,
wITH REGURSIUE pakrn AS
SELEC 20 fAS n
UNION ALL
SE LECT n-4
FROM Pathern
Paint p(20) wnERE
Recusive quey ymy
SELECT REPEAT ('*,n) AS
wITH RECURSI VEJ ETE-nome As Towpatern
sELEe1 4uy (B qusnte FROM paternj
UNION CALLJ
gEUSC14uy Reentveqwy waing REREAT (*',)
)
SELECT CTE_name;
numher fran 1
to 10 without
functim.
RECURSVE nutn bers as
On
(SE LECb 1 as
n
UNON al
SELECT nt 1
fRoM mumbers
here m210
-from umbers;
s elect
nuMberg.Q pint pame
rnt no -from 1to
|000,
4Seperatt pume num ber fyom
wITH RECURSIVE temp as
Selet 2 as n
(nion a
Select nt on temp
where nt| <|000
),
Drime ad
Selet n from temp:
there nat erist (
Selet from tempad d
Selet qcub-concot (nserAPA ToR '')frm pom
tn S .
Not pyend ins S9L ( UN loy ead )
L J°|
SELf 10N
Lilatsian
kmotehng
’ Retun trom t tote
ON (Ondeton ognt
c t e tHen t
tany an (onse a e n t pgiets Comple
`am peject
fond tott no usted by no
proyeett
na dote of
end date
Stat and
output
doy
SELECI
CASE C t ) e 8 )
OR
wHEN [Link] BtcL2A
THEN Not Brc)
ATuaneuEN Egulatyt'
hn l A=8 AMD Bc) THEN THEN TSoceley'
When A-ß oR BcoR CA) hEN
SalsLe'
WHEN (A(=B AND B=c 4N0 c!>4)
END AS
triangtybe
FROM TRIAN4UE
SutcleninT(Nlamty'l',tt |(Ocoptvm,),))
fRonm (ecvCAteNC
ot (ount (Owhoha)
totat of,
SEAE C1 cONCAT ('hene are a tofa
, (ouey (Ocupstion),'s.')
CROM oCcUPAT lONG.
GRoUP By occupoty
ORDER 6Y CoUNT (Occupotom)
Occupationy
me
Taslu to pivat Conersion
ParttonbRK By (conopt)
Windofonhn.
[patit1on by [Link] aa may-Sley
max (SalayJ our
lag
rowNumber ra, dane TankyTead t
sn
Yo)number ) oueV|pateton by dept_nam)
Seteq
eder by enpidy
- Yow number)oer[poti, by diptnan
ranl) over(patton by dipt. nans
supdblitk Valy
Qense Rak
dense ankl )
Lvalug
columa
sptnamc o
(pautt ton
by
Over
enp-td)
peen 71
Selgct
NAX(IPpceuPATION "DoctoR"jNAME,
NA,NULL))
='hOFECcop, Stingi
(2f(OccupATiON
wAME, VLL)}
Min =SINGEK,
AAN(ZF(DCepAtiON
attan By Deupoton
ouer
Row_numhr()
CROM
by
ncne,
oceupati'en,
orupotme as od goup
(Select rou_num fRoM
ORDER BY h£me )
as
Bo a'sK
S t t l N,
CAS E
wHEN P TS NULL TI
to defermns
wte an S queny
TSelet fkON employees
uim't 30 hirt g0
Selut
Ppow woRkER
ORDER BY Salo
you'
ttre
oboue quwt
exsts
extk A Not
wut s qucny to fetdu st
Same' lala
Select wi. *
Salany - [Link]
AN DD [Link] id
-te,
an
Select mar
RON warer
(Salay) a
(salony ) frm kr).
tn ( Selict mar
PRoN wor
whene
3 (Ote an L quey to ghow
Seect PloM wtr
FRo M wOEK)
ODER By word)
anl
t
to ust vDror id ubo dnaonet
BoNUS)
Select
shgye ttittekret cechfeoetKefa-or
thot has ley
fRom w o r
depadment
aipcount <9
w)
table.
Geleet
ar(woar.t'd)
wO erid = (Selet
hee
ue record!
E)ite an saL query to fetch the lat
from aa tabla
der y waertd dyc lnut S)
(Gel eet t fom woter i
)4s) Mt an
Sq qu opunt
t p,k
eu name
Se lect cw dupatmot, wfirstnam, -saley
FRo WOer
qroup by dapotment) tenf maxs
TNNER JoiN
ON [Link] 0 a i p a t n e n t
10 ma tre
s
to fec
trma tabu
wO ley w
Seloct distnct salany fron
uehere3> ( celect ountdistnct
usere [Link] < w2salaA
ORDER By ws-goo duse;