0% found this document useful (0 votes)
12 views21 pages

1 7tables

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)
12 views21 pages

1 7tables

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/ 21

NI &

••v ••t1111111h• ... ••lll••••I


Wlktt •nrdallQl, . . IQt.oP.,aa4e11tp11tllrMe...-.

............ -..
Cat JJIIJ Cir

-.... .....

l To...,.., ••□• -, ta.I 111 □1 w1aw ■--e atarta wttJa 'C ta


uo. . . . . . . . ., ....

IL T• d1e,1a, - - . ltea .... ud C1tJ of tlae prodacta •II°"'


....tttJ la.._ tu■ 100

IL Ta 11at ■ ttw ._.,.., .... ,,_ tlae tua.


iv. To insert a new row in the table Shoppe

110, "Pizza", "Papa Jones", 120, "Kolkata", 50.00

,I t\J I I \ 1-I I 11
VI [ll
(,. ()
l p• • l { 1' ')
I I (\ ) ( C.. J , ' I ' \ :) I,

"· SELECT Item from Shoppe

WHERE Item IN ("Jam", "Coffee");


"T" j '

vi. SELECT COUNT(DISTINCT(City)) from Shoppe;


,
( l
I
\. )

t 2
l
\'il, ~lt\,tC'\' MlN("lty) frnm Shoppo
WUltRE City• "Mmuhl\t'';
t 1\I ~ J
1
f'.\ '"

1
1b

viii. SELECT AVG(Pricc) from Shoi>po;


WHERE Qty>100;

ti v~( (\·~t e;
2l. t,

3
Table · 2
2
Q , ObRcrvc the table given below (EMPLOYEE)

Write command of SQL for (J) to (vi) and output for (vii) to (viii).
C.W..w IJ1;rnu
1330
HA1,1r 11
fllilhry rlow I11,I11,y l,(JJ a, ,m, 14 01/AIH t I
l"O<iO l llf,ljO
r,1 A.r 11-:1 :,01 I Oli 0-i M HIMAYAI U/\C.,i.A,II
1331
rioooo Mooo ;.,01i, 10 11 F nrGllJMPr r
131:;>
PAWA1~
l.r!,00
Oll~Oil1 /0000 :?OHl 11 12 IA KUKArr l'IU V
1333
llOMt\
C,Ul">Tt. !iOOOO eoooo ,01110 1 F 111QI~ 11 C; CITY
1 '1 S<l
A.JI y
NAOl\rc
o~ooo oouoo 20Hl-01 20 IA 111MAYA I f//V AH
1331j
TI\NfAAV 67000
OIIATr 00000 ::>01G07 20 M ur C,lJMP I
13'30 HIVAMI 10000 00000
AH.Of<A 201104 1l
' IIIC.1 I II CITY

(i) To display names of the employees, aalnry, new sn ln,y from


himayatnagar branch.
f
I I

,, f t I t ~ I I

(ii) To disp]ay branch wise count of the employees.

t I

4
fw1 TP
....dlaplaJ tlM - - • ol llae emploJ•• ba¥lq a date of Jot••••
tllaa3011

lrQ 1111111u-. ■■•<--


Vii) SELECT BRA.NcH,MAX(SALARY) FROM EMPLOYEE GROUP BY
BRA.Nca HAVING DOJ<=2018-18-18.

viii} SELECT MAX(DOJ),MIN(DOJ) FROM EMPLOYEE;

(·'IA, 1 00"j \
l /

_:::01 ~- c.\ d

6
Q3. Obaorvo tho t•blo glv.,,. below (llo• l'IIPI)
00

[~o Writ a
Namo
Sn11ctoop
111nuuu1 of SQL 101 (I) lo (Iv) 11h11 out 11111 r.-,. !vi " (viii),
Auo
G4 nopart,nu11t
1

r23 ~ 24
l3111uu1y llnlv.QLMfil f:lliUUll!I 011)(
:.! IAl.'ltl!I
t<orun 0 1lhOf)(ludii M
4 t'(l/111 fl.Ill
01t11opou11to
5 S111gory
1(1,\1}}\>:1
M
6 I NI 01/1>1/UH
I
7 IJ/llt/011
E.Nl M
8 i .i11l//t1U
n I El ___~9
Za~en 45 Caru1ology
9 ~ll/ll.'/\111 111~1
Kush 19 Gynlltlc:oluoy :l,VU,!/1111
1Q_ ;/0(1
Carlholcl\;JY
fil1a,1va~ -~ 3f Moctlci11n
1,11\11/tltl ll(Jll
M
111/tl,J[III •1011 I

{i) To list the names and nge of fomu1t1 pllt hmt I( who ltl'ti 111
orthopaedic department.

,[L[, tvo r,.~t- {~ ,r\ 1111 : 1 \l


1
'.\ri\ i:.\ r ,~.' ' ~ l<-1\ \ \ I~ '

(ii) Increase the charges of male pat·ten t in ENT depart mcnt b y '311•"•

7
(HJ) Delete th t
e records or all female patJe.nu In Surie.ry departmtft

(Iv) Di1pl1y lht dttal11 of all Uit PU cntJ •ho u


1998 d

(vJ SELECT COUNT(DISTINCT lltput c t FROM HO P A


lvl) Bl~UCl'T MAXIAI\,•) li'llOM llt1t1pllJll w1rnmti flo1' •M'I

f II l '\i
!' I

vii) SELECT AVG!Chur,;ct1) li'nOM llollpltul Wmr,rm Hl~X • 1 Jr 1 ;

iii) SELECT SUMIChnrgcs) FROM Hospital;


\

9
(,lll , Oh!lio1v,\ tlio lril1lu ijlv, u l.oh,w jf-h111u1 ,d>H)
W, 1, 11 '-'Ullllllhll{I ~, fl(JI_; lot
(I) lo ('tll) 111,d out J"'t 1111 (v11) t 1> ( !'Hf).
.lW.U 111 Ult
!11 ~N1uu1
If I llUI•
llJ
tl1'1(! ,. 11,1..,11 ••• 110
l'11, tt

lhll,hO
j1AillDA.~.JIJSlllil~A.
j
14 1OIJ I (.M'l tj ,.,... ,,,,,.try
l'dl11ilfll1111u1I lti,hh Hof Ju,J,.11t1,11~r}1,
IUOIJ:A lttl 1r, Mt1'1lc ••• lf11r3a1JII
.Nobl1l1,1,t f.{l,l)(J
My~J11J,«1tl1t Jts,J,,u,l Guden,
I( IOU I
t,t, •~ 1r:o,tJo Mv.~b..w.ul1l
lJtillil
Hll>OIS ttc,.11 l lf>.O() Ul1UtiJW.iH101.M
HKl'))~J/IJfllY. H•mth
Kt1~JJ..,J2JJ,~Jhl

(I) 'l'o dl uplny t htJ IIOUlOfl of drugn tn dine wllh 'c'.

1(f I1 1 l, I"'''

cdicines whose price is in the range 100 to


(ii) To displny nll those m
150.

, nr, r>'IO.. V15

I 1
\
tr
ri u· L - '

10
(iii)
JGourgaon
displat'.the Maximum price offered by pharmacy located

(iv)
To display ~he Drug I~, DrugName and Ph~rmacy Name of all
therecords 1n descending order of their price.

<;c l fer () n,fLO, Or v~NON\9 'Ph(l}rt1a(dl\Jcv·1'\.0 1-·.,q()/V\ Pl,U-'IMC\08


OR.DfR [s'i ~)°)((: OfSCj

(v) To display the average price of the drugs.

Sf LC er fnJ Cn (Pri'ce) F-Rotv\ ?kl\."r'Ylfl- O(?,;

11
'" ,._. 1 wh lh1 l

n u,N• Phar aDB w r


" IN lb Par Raj lhid

LEC-T Phi a Na
Phu a Jh
11111111"~·

I i•h!• f:
QS, Obtiorv, ti"' lf1hlo gh1f'i11 hilto,v (filVMI

W, ito C1om111n1ul of fl(JI1 lur Ill In (lvl r.1111 lHil JIiii (111 IV} , o lvlfl)
lOOn1t INAMlC 1•acm10 HHANUNAMl'1 1
0 l Ol 2 0000 l'owo, U;yH1of!
E,ulle1l■ti1
0103
A11m, ll'lt 1800 Jloltul,Jc
ltxarnl•cn
0103
C101e Hlkn 14()00 If,, ot,jlc,
0104
!·w\ol_!t,r JUOIIO Cnttt:t11 •
Ext H ) ll16 Oym
0106 M6ii1U1[;~ flnli 6000
G106 Cro1u1 Trnh11 , 13000

(l) "I'0 dt sp Ifl}' tl lC TlfllllCfl n f n11 ti 10 It ,•mn wt Ill u1 11 .•1, ,11, eto,, ll with A,

\ I l r I

" nncl INAMgs of nll ltcmo, whone Dr ,ndnaino 11


To dlsplny ICODEs
(li)
Rclinble or Coscore.

I I
uu,
To cJaaaa• tbe Brand.um.- to , t Tr dI d
ICOD& •• 0101

(fvJ
Add • new row for a
0107 Vibro x r

V SELECT COUPfT DI TIMCT


22Ci!.£§@

(l,i) SELECT MAX(l'RICE) h'ROM GYM;

/' , r

I
vii) SELECT !NAME FROM GYM WHERE INAME LIKE "•t";

1 tlf. f\t
f ~ e ~C•oe \>r'V.

viii) SELECT ICODE FROM GYM ORDER BY PRICE;

'.1(1\0f
("IO'l-
(/\10 5
~10&
G Ir\~
(n I :'l I
("lu'I

15
Q 'l'rt hl<' • t,
11
r, ht,"""• •• 1•hlo alvon holow (llllVl!'l,:S)
IVrlt• ~0111tnh11,I of S~l\, l01 (I) lo (Iv) ,11111 milt>ul for (v) lo (vlll).
l~,,, l' ll l NhmeJ
l ,, ' I I I
\ nov t,,,1
\I \111 ~:1 II· t, Snlnry HirlngDutc
111'
\ \1\11
\IP~I \N\ 11 HOOOO ~0 18 03- I 2
I I
l•'I I l'li'I ll H ll,
\N1 11111 \\ 1n~":, 1
fl.lt\t..' I IUt lK
82000
\) \ 0 I ' I 'l{l l
ltt~\\ \ h \I\ \N
\ Sll~
1~ \ l'l I 78000 20 15- 07-21
\)l'l l\ 1, ZI• Nl:il )0 1,
~ \ i\\ \ \ I~ \ I N \ \ ('Fl{
1)(. \.t,,, ~ll Ml l' R \ Ul~\\
l~l )l1
75000 20 19-08 -23
Zl•'t>t I\ l~US
lWOD 1' \ NM\\ ltl l \T IIP O~tFN 75000
\ )H ' lhl 'I \hi!~ 1,ll \ N 20 I 8-Ql) .20

,rn [85000 2015 04 -05

(i) To displ.,y Nnm,~. EmplD nnd Device of cniployccs with Salary


mcH·e thnn 79,999.

'\ \
.'
\

{iij To display Ntune. E mp ID · HiringDnte and Device of employees


having Hp. nn d 1111.IACBOOK Devices.

\ \
(iii)
To display Name and Device of employees.

(iv) To add a new row of values ("DD096", "ADHIBAN BASKARAN",


"LENOVO TB", 77000,2020-08-22).

'.l•~~fki r_r_Tt, 'Oe,itt, \IA,u(~

( • 0(,\%'? 'P...v• 1~ftil U· ~r f<kJ\ LL\ MlJ\J!\ ,- ', 10•' ,11r-1 L• )~

(v) SELECT Name, Device, EmpID FROM DEVICES WHERE Name


LIKE'S%';

,,(\... ,(
0 VI( f> L Mf.:. \,
\f.?-\P. "{ ~P.l fl. p. 1),~ I< H< ...'\ 'f J Or 1 .;

;,..r \• 1 SA- J1:P., K C, Z~f •vp , I\"~~

17
(vl) SPLEC1' MAX(Snlluy) FROM DRVICJtS;

I'
[·I
II

vii) SELECT EmpID, Nnme FROM DEVICES


WHERE Salary > 80500
ORDER BY HiringDate;

( \ f (l

-:. AV; • (I. \< I f'\, I

ft.1 ~P.-1 (~ ~
\ l

... i SELECT Name FROM DEVICES


I~111
WHERE Salary< 79500
ORDER BY HiringDate;

I '(~r()J..
{J: ,Yj ...,Pt I P. l 'I fi-1 I f,
11.,, ,r ().. I f p.
~r.. •(. I ff t l (1

~JI 'i.'T -; (\ I A!

18
Table - 7
Q7.0bserve (TABLE.7) the table given be!ow {WOR.Jvt"R

Write command of SQL for (i} to {iv) and o~t::~t fa: M ~ ~ :.U7.
Work end Name
001 Monika Arora
002 Niharika Sin haJ
003 V1Shal Si h
004 . Amrtabh Rao
1ooao
005 Vrvek Goenka
28000
006 . Vi ul Shah
45000
007 Satish Modi 62000
i. To create the table worker.

(/;.-r1f 'Tk:.,lf
I
1-kil(,- 1-
- o ·.:.- 1\.. , -C , " -
;:, -:. •
' ~
L -, '

h,1e,.,n~ Jtt'f.. •1ry<c , - ~ •

ii. To insert a new tuple with the data (0OS. Gee thi.h, 'i 4 00t). llVr. E-
12-24, ADMIN).
Ill T .._,,.,, Ill• lht1I I all th• w tktt, ,r IIM ~ p,111 ♦nl

iv. To d.l1pl1y th~ n•m~ lllary Ind dtplttmn,t or 'ilr rk fi


11eendln1 order w rt J ln "I dat

SELECT MAX(Salary) FROM WORKER


vi. SELECT DISTINCT(Dcpartmcnt) FROM WORKER;

\ \ r-...
~11''1/\'
J\.._l ('" l\\'I

vii. SELECT Department FROM WORKER WHERE Name LIKE "\1% ";

0. \ l.'\h,_. ,\
\ 'r,..

iii. SELECT SUM(Salary) FROM WORKER:

You might also like