Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

alssMAte

Date
Page

SQL Interview a/A


Ahat ae ell the diffexent novmalfzations
Data base noxmalízations can be easily
undexstood uith the help of a_case study. The
noxmatoxms can be divided into 6 foxms, And
heu aYe explained below:

1st nd 3rd Boyce4th 5h 6th


hoxma normalnoxmalcoddnfnoimal nofmal noxma
Fom form foxm form Poym.form
Data base Normal foxmsS
zite an SOL QUeru to fetch the count of
emplouees NOYknO in 2 rolect R1
Heie, l e nlbuld beusinq aggxegate unction count
) mith the SaL Wlhere clause

SELECT CouNT (K)_ PTULKmaL UNKEDI)


NOTES CMGRY CTEERANA).
FROMEmplouee SalaYu
WHERe Poroject P1;

e an SaL QUesy to fnd the emplouee ld lhose_


calaru les în range o 600 and 15000
Here, wle can use the Betueen 'opexatox i th a
ahese clause
SELECTEmp [dd SalasyL
FROM EMPloyee Sajayuy
lNERE SalaryBETEENo00 ISooo
1
elassMate
Date
Page

Aite an SaL query to fetch all those eMplouee


LAhose on_2rolecE_otheY thanP1
Hexe Jle can use the OT operatox to Fetch
the roS nihich are not satiskging the given
Condibon MuL KomRLINKGDIn)
NOTES GLERYTELE M).

SELECT EMP rD
FRoM Employee Salavy.
InlERE NOT PoJect = PL";
Ox using he not equal o Operaox
SELECT EMP ID
FROM Employee Sal ar)
W ERE Projec<>P1

e an saL dueu to dis play he total Salary


Of each emplouee aAding -the Salau leith
Vasioble value
Hese, e can simply use the E'opeya kor in SQL.
sELECT EMP Id
Salary t yariable as ToralSalaryy
FRoM EmPloyee Salary

zite an seLquexu_o Perch the eMplouee full


name and yeplace he S12Qce uith
Dsing Keplace unction=
SELECT REPLACE Full Name, ')
EROM EmPloyee Detaîls
clAsSMAte
Date
Page

ite an s&L aueru to fetch the EmpldS that aye


2xerent in both the tables-_
Emplouee Detalls Qnd Employee Salaxuu
using Subguery
SELECT EmpTd FROMM
EmPlouyee Detalls
here Empld IN
(SELECT EmPId FRoM EmPloyeesalQry);

slte a saL quesu to fetch he Emolds that


a e p7e sent in_Emplouee Detalls but not in
meloUee selayu.
Using Subuexy eTuL IomeR LiNKEDIn).
NDTES GMLERY CTELCYRN)

SELECT Emprd FRoM


EmPloyee Detal|s
Whese Emp Id NOT IN
(sELECr Emprd FRoM Employee S al@yy);

Wite an saL Queru to display hoth the Empld


and angaeY Td oa ethex.
Here ale can use the coNCAT Command.

sELELT CONCAT CEmprd,Manages Id) as Neo rd


FRoM Employee Details

3
sSMAte
Date
Page

i t e an SQL auexu to upp eycasethe name o9F


he Emplouee and louseYcase he city Yalues.
l e can use sQL Uppe1 and Lower ancHonso
achieve the intended results.
SELECT vPPER CFull lame), LonlERCiy_
ERoM Cmployee Details

ite an saL quexU o u12date_he enMployee


names bu emoving leadina an d alling Seace
Using_he 'Dpdare Command 9lth the 'LTRIM
and RTRTM function.

UPDATE5 EmployeeDetalls
SCT FullName LTRIM (RTRIM
= CfulU Name)) >

ite an saL query to ind the CuYent


dare- Rme
My SaL PMUL KomRULINKGP N):
NOTES aMLERY TEEUR).

SELECT NoLO C 2

SQL SEWes-

SELECT Cet dat );

OYacle
SELECT SySDATE FROM DUAL
elAsSMAte
Date
Page

etch_q the eMplouees Aho arenot 0Yking


On einu20iec
his is one ofthe vey basic inteniew
auestlons in which the înteyyiewey Alants to
see if_ the 2erson Knos about the commenlu
used -TS NULL opexatoy
SELECT EmPtd
FRoM EmPloyee Salary
WMERE Project [S NOLL,

Write an oL queYu to fetch allemplouee yeoYds


om emploueeDerailk trable lNho havea alaru_
recoyd in Emelouee alaru able.
Usina Exists' eTuL KeompR LNICEDIN)
NOTES qLERYCTELEYKAM)

SELGCT& FRoM EmPloy ee Oetails E


HERE Ex1STs
CsELGCT FRom Employee Salary
WyERE E. Emprd =S. Emptd)

You might also like