[go: up one dir, main page]

0% found this document useful (0 votes)
11 views13 pages

SQL - Notes

The document discusses SQL commands and their functions for managing databases, including retrieving, modifying, and deleting data. It covers various SQL operations such as SELECT, WHERE, and GROUP BY, along with examples of how to use these commands effectively. Additionally, it explains the use of aggregate functions and conditions for filtering data in SQL queries.

Uploaded by

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

SQL - Notes

The document discusses SQL commands and their functions for managing databases, including retrieving, modifying, and deleting data. It covers various SQL operations such as SELECT, WHERE, and GROUP BY, along with examples of how to use these commands effectively. Additionally, it explains the use of aggregate functions and conditions for filtering data in SQL queries.

Uploaded by

blocksystem72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
VAN ALY \ peach faa x a [aA Tysed fou _accéssing oral aoncdelifiging) Lomquage | SQk atomas fon Atiuictwre gugup Lornguage — Lanfongen. oto wn the doalabase. sel 16 mon pnocedunol wnglish Like Aoroguage Hw ar —Tthat nocess tata wn a grou of seconels — f \ dhom_one _reconad at adime. Jao fumetions of SQL ane:stoned dada modify data, netrteved [KA dota amd ocote tthte otc: Ow ee ee a _a| SQL -Commomds é= | PALO YER commands ane masburckion ured to communicate With the databace do peyonm, porné (Gske Lhat ss0rk sith dota sat Lommamds com be used mot ontp for seanchimg the dotobore ut ahodto jourfoum various ofhur fumiuliom tke owote table, add data fo cable, modify dot ,dnop the Aable , set permis ior for UAU+S. 38h Cornered Ayes © _boL (Rata VWefwnilion Lomquage) @ BML (Dasa Moniputatign kamquage) @ Tel (CYransacdion Contiel Lomguage) @ ect C Zata Contaot ham guage) ae of a Sofabane Leflore homnguacye 2 Where SQL Commands ane Used fon creodang aanodifiy amd d.0 ppoarng {rndure aot database nub fecks. Prise commands ae Oveleot- reresteck Lotter Pdnop Quename @ Dotobowe Momipwlelver Lam rng uti There sel commands ane used fou along, | retrieving oma amodifyang amd deleding dat These commomds ave Oselect Supodate Crrnord, Land Detete. @ Unomaction -Cominot Kanguacpe 2— Whe SQ commands ane of or Aenomagrg ChOmngzes Ofte cng the data, “Ineie cormmeands One “comm sit notatbac kK Gmd_ save port Rota Control & wages — hee SQL commom Ate used for Joroutding | Aeour ity do database objects, Whie com ane rion nevoke - wos eH © Dulend willed 2 The acco uscd conmomnd ws Archect U da fal os 4 ° am. atodowm ~ Tf 1s use gy 2 ; Loefrieve cota from aftabde wn he retrieve wmmtfouwmation a ‘ Beg ‘d_ columns ov alt the columns im he toble. it Buys ace : s@r> AeA column List som < #bbdenome> [where clause] [ Group by clause J [itavang clause] T onder ) clause] : Ve \ Vales fare & classmate. Date e 2 bie (Jo Alaspol ayy au Ahe Angowmadion, of Aabte of 4 Pant = y car > Kelect oll mame, acm fee doa the from Atudenk 5 Sqr >Aelect #ferom student + Eleminatang neclunclamt dota uith olistind Ap wonels tH default data ts nelecled fwom all Ahe nour Of odote vey Af the dota Appearing am the ew guts duyplicated the dian” Reyuoord thinnin ct es uuplicoles arom the neuults of a sdect slatemeont. ‘don LP 5 Sf the chudent Adble Afores Ahe mores. of the Lifves_of Ah xe students _and_we want 1 ace the «thes Whore the studs belongs Ao SQL> Adhech ctanct Chey? form atudenls Se eee + [whore clause J 8 w ce whine clause ace Atotemernt ppecifie the _cnitoria for aelectiow of ef rows to toe _srtetiwmed ] | the rtollLmo, nome omel fy do duspl “acmnfee fon! Aticlemls bawing ely Boe admission fee *more Ahavy 3000. sq > select naltno, nome, aamfee T feo studevt | Whore admfee 5000; Ao display all mbowméeticn of ptucl ents | whose hy is Ramdhoiand methine: amore thom L001. i S@L> Achect city, nollno name. admfee from Aludents Where aollno +1001: where cily = Ravcht, OR Sal SAclect # from Fil Where cihy =' ~ ty Ramchi! and walsos one dea | AN, —— AA q Condition. based on a Home t— BETWEEN Ope1aton Aefhines an ; Orn ee that the column values Mere jwlo Amake the -cond” Anne, Whe van « pl and 5 both +tever lowes value and Wpper_yalue. Gq:c do Mist Ahe stuclenilk whose _vollno bel w Leg 1005 to 1040, a T sary select # from ptudint where aollno BETWEEN 1005 and 1010; oR sal >Aclect * from Atudent Where vollno > =1005 AND xollno < = 10105 The oporotoY NOT BETWEEN nevowe of BETWEEN obeorator te the nows mot sod thy ting, Ahe between cond” ore _nelrieve. fo:- Jo Anntdhe students whore voll no. a i alpaca ea al SQL> select * from student Wheve voll no Not BETWEEN 1008 amd 1olo, a dust 2= # Condition. barcd om Ga pecs a Lust FF values, IN perodor i d IN operator nedeck yaluts that 1nd + even Wt of that wnolchy ony value an Og Bq fo displ ty C at _f rtudemt from wRamtlvi, Ketdeed@= anrcl- qBokano amd | “Podme uber '— I [seus Aetect_# from students _ ) | eaheve city? IN CRamchi’ ‘Bokaro’ Palna’); OR : sQuy Aelect.*« from atudmw [where cityp = Kamchi oR city “Bokaro” oR city = Patna’ } Dhe NOT _IN oper ado funds secord #Ahat do met match rn the {uct Sg t- sal> Ade * from ptudent a ; ; where oily NOT IN Crancht’' Bokaro’, ' patna’): OR i s@L> Aclect * foromr stud ml where city <>'Ranchi’ oR city<>' Bokaro’ oR citys> Patna _— | ar also eer dean Imad chino, i ° Oj ve LIKE fon comp arthons ow ovate piangs. Lom pattinn, “Potlen are al d g - . 8 quscrabed Madang) #090 _Apecial paid carol || characte . | . mach ec (om (parcdwtage) :— dhe 4 haraclor amy? sub ate, : —7 @_. (Undoucore) i= “Whe _ chanader matches | oy character: foi Uo (ul the stuclorls whore mame whats "wth charactor A SQL> Aclect * fpnom student “where mame LIKE SAX? 5 eg: Vo displ al dhe atuclemts smfo _urhose mone nds _with chavacter .M, s@L> Aelect * faom student Where name LiKE'2y? . EG! Jo_Ust students who have four chanacter home ending with ~, UO SQL> Aelect x foom atudenk: here name LIKE Seeas\ CT ) i ly aad la a eo =s a a | # ocanchme for Dud be = Line a column — Whe NULL Vv = pabhe using) Js NOLL seanched fox a ; (Petes openrotor, av Ahe whese _¢ = oto Aike = < comnot be Us with NULL). lego Aud delads of lucent Ghose city nian NULL value SQL Y Adclect * farom Atudems where _culy 1S NULL; te Orolen bp Clause 2 “She _onden by CAoamse allows Asabordarng of queny reesubt ton by Che «4 0r more columns. “Lhe sorting com be done etther Wwe aacendanag On dérscendang onder “he def out _Onclen ais ascending ° x €g: “Jo display Ane Aust of sjudents an deseemcl yn of Aber nommes whore adm fee | ws more Ltn eke 5000, | SAL > Aclecl x from ctudent | Whine admfee S 5000; Onder by name desc - Ser ey —— | pAggueg ote “dumetions = “She Aum aie gf toe dele 2 oh 0 yum 7 agqnieg obey oO. Ag gic gee omc applaed Ao aus MOUS An a tably & toa 4 caubset of Me fable apecfied by a whore Telawse. 88t sncluces otloirine “fumctions: QQ dumO > To catulote dota values. @ AvpO i= Jo colcutate avenage value. G@_anoec0 :- “Calcul ate _smax™ values. @ awn !— Jo CalewloAe min™ we value. O Com O Jo coumt Ahe mon-mull_ values an a_ycolumn. @ -Cound (*) = To _coumt ot el_mo- of Hows am _@ Able . £9 Jo coleulate the total cdmfee or atucents & city Ramet — SQL> Aelect usm acimfec) [rom Pasion, whore colby? = ='Ramchi” Bete | ie fl Eg! “Jo dusplay Ane. avg. ioe {oon _Atudenty © amd Ache Aber ye anomnes began (sath A ¢ a do coby Ranchi s@L_> pled avg Cadrmtee) from atudent “phere narmne: LIKE AZ’ nd city ='Romehi?- of Muchas aw Audits gato coum the mo at able 2 : cal» Aelecl couml C4) from Students diff. e9*"Jo count Ahe ane of cuties rludentt hifongs do : —-—$________— sar» Aclet couwl (aifiowcrst cbies) from pwludonts 5 #4 Groups by 3 Chose — The group by Lause as a am _aclecl otocle fo dtvide. the aable 3 groups. noupang cam be done by & column mame ov @tth -+the aggregate fume aw_whith case Ahe aggre gate avalue for each grtua® poreuces egal calculate the mo. of vpudents Am. ra omd_avg, admfée {ev each cé for _atudent ?— : 3 dtudents Saby elec city count Cx) _avgladm fee) rom grows by city - = (ee A Hana Chanae = Whe Ayavon clone _potacts Lon” On pos am conned whire chase thod” places cond” on Andividacd pn ouss. to - [gto display the cities / 2 Sy lr sei aad tis thom 5 Om ehh. also fo | derplau, fot a L adinfee fou cath ties. Stores SQL > Aetect city, count Go , sum(admfee) from vtudent having count CH) <5 grotip by citys tt [ot asdeo0 rkKy—*& ino | Name | subject [avgamarks | Grade [alan _| 1 | "Kastan Physics Wes B 128 | 2 [Bivakar [chemistry] 24-2 A ite 3 [Bivya |chembtay| 68-6 e Ize 4 | Anu Geology 413-1 B 12¢ 5 |Aabina | Mather 9-« A 1A lien) Jobn “Physres qS-4 B | Iz6 et 7 | Kebeut Geology. | 64-4 | c nA a | 4ab TAmwer the Following question on the basts of te Atudent - “Ol Aclect att the ctucents rtudy log “Physts spor phe Aolole student. OlAcdt de aluders corded ey avg maria by ascendiny ondiv. @l_-Comd the mo. of students securing grade A \ the momen of pfu.dents aeweiny B quate i G Dasplay Lhe outpud of sind min" avg rnavks from. the _Adcble atudenls,

You might also like