0% found this document useful (0 votes)
2K views45 pages

12 Practical File 2024-25

Uploaded by

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

12 Practical File 2024-25

Uploaded by

adityabala180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

lOMoARcPSD|40449340

Class12CSPracticalExercises2024-2025

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

COMPUTERSCIENCE
PRACTICALPROGRAMS
FOR GRADE –
XII[2024-
2025]

Preparedby:

1
Downloaded by DISHON raj ([email protected])
lOMoARcPSD|40449340

TABLEOFCONTENTS

S.No NameoftheExercise Page.No


PythonPrograms
l. Creatingamenudrivenprogramtoperformarithmeticoperations. 3
2. Creatingapythonprogram to display Fibonacci series 5
3. Creatingamenudrivenprogramtofindfactorialandsumoflistofnumbersusing 7
function.
4. Creatingapythonprogramtoimplementreturningvalue(s)fromfunction. 9
5. Creatingacsv file to search the password for the given user-id. 10

6. Creatingapythonprogramtogeneraterandomnumberbetween1to6 ll
7. Creatingapythonprogramtoreadatextfilelinebylineanddisplayeachword l2
separatedby'#'.
8. Creatinga python program to read a text file and display the number of l3
vowels/consonants/lowercase/uppercasecharacters.
9. Read a text file and display the number of vowels/ consonants/ uppercase/ l5
lowercase characters and other than character and digit in the file.
lO. Creatinga pythonprogramtocopyparticularlinesof a textfileintoanothertext l6
file.
ll. Creatingapythonprogramtocreateandsearchrecordsinbinaryfile. l7
l2. Creatingapythonprogramtocreateandupdate/modifyrecordsinbinaryfile. l9
l3. Creatingapythonprogramtocreateandsearchemployee’srecordincsvfile. 2l
l4. Creatingapythonprogramtoimplementstackoperations(List). 23
l5. Creatingapythonprogramtoimplementstackoperations(Dictionary). 26
Python–SQLconnectivityprograms
l6. CreatingapythonprogramtointegrateMYSQLwithPython(Creatingdatabase 28
andtable)
l7. Creatinga python program to integrate MYSQL with Python (Inserting records 3O
anddisplayingrecords)
l8. CreatingapythonprogramtointegrateMYSQLwithPython(Searchingand 32
displayingrecords)
l9. CreatingapythonprogramtointegrateMYSQLwithPython(Updatingrecords) 33
SQLQueries
2O. SQLCOMMANDSEXERCISE–1 35
2l. SQLCOMMANDSEXERCISE–2 36
22. SQLCOMMANDSEXERCISE–3 38
23. SQLCOMMANDSEXERCISE–4 4O
24. SQLCOMMANDSEXERCISE–5 42

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:1
DATE:

CREATING A MENU DRIVEN PROGRAM TO PERFORM


ARITHMETICOPERATIONS
AIM:

TowriteamenudrivenPythonProgramtoperformArithmeticoperations(+,-*,/)
basedontheuser’schoice.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PythonProgramExecutedOutput:

***************************************************************************************

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
2DATE:

CREATINGAPYTHONPROGRAMTODISPLAYFIBONACCISERIES

AIM:
TowriteaPythonProgramtodisplayFibonacciSeriesupto‘n’numbers.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PythonExecutedProgramOutput:

*****************************************************************************************

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:3

DATE:

CREATINGAMENUDRIVENPROGRAMTOFINDFACTORIALANDSUMOFLISTOFNUMBERSUSI
NGFUNCTION.

AIM:

TowriteamenudrivenPythonProgramtofindFactorialandsumoflistofnumbersusingfunction.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.
7

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PythonExecutedProgramOutput:

************************************************************************************************

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:4

DATE:

CREATING A PYTHON PROGRAM TO IMPLEMENT RETURNING


VALUE(S)FROMFUNCTION

AIM:

ToWriteaPythonprogramtodefinethefunctionCheck(no1,no2)thattaketwonumbersandReturnsthe
numberthathasminimumonesdigit.

SourceCode:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SampleOutput:

**********************************************************************************

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:5

DATE:

CREATING Acsv FILE BY ENTERING USER-ID AND PASSWORD READ AND SEARCH
THE PASSWORD FOR GIVEN USERID

AIM:
To create a csv file by entering user-id and password,read and search the password for given
userid.

SOURCECODE:
import csv
with open("7.csv", "w") as obj:
fileobj = csv.writer(obj)
fileobj.writerow(["User Id", "password"])
while(True):
user_id = input("enter id: ")
password = input("enter password: ")
record = [user_id, password]
fileobj.writerow(record)
x = input("press Y/y to continue and N/n to terminate the program\n")
if x in "Nn":
break
elif x in "Yy":
continue
with open("7.csv", "r") as obj2:
fileobj2 = csv.reader(obj2)
given = input("enter the user id to be searched\n")

for i in fileobj2:
next(fileobj2)

# print(i,given)
if i[0] == given:
print(i[1])
break

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

enter id: cbse


enter password: 123
press Y/y to continue and N/n to terminate the program.
Y
enter id:computer_science
enter password:python
press Y/y to continue and N/n to terminate the program.
Y
enter id:class12
enter password:cs083
press Y/y to continue and N/n to terminate the program.
N
enter the user id to be searched:
Cbse
123
>>>

***************************************************************************

10

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:6

DATE:
CREATINGAPYTHONPROGRAMTOGENERATERANDOMNUMBERBETWEEN1
TO6
AIM:
TowriteaPythonprogramtogeneraterandomnumberbetween1to6tosimulatethedice.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SAMPLEOUTPUT:

PythonExecutedOutput Program:

**********************************************************************************

11

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
7DATE:

CREATING
APYTHONPROGRAMTOREADATEXTFILELINEBYLINEAN
DDISPLAYEACHWORDSEPARATEDBY '#'

AIM:

TowriteaPythonProgramtoReadatextfile"Story.txt"linebylineanddisplayeachword
separated by'#'.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SAMPLEOUTPUT:

Story.txt:

12

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:8

DATE:

CREATING A PYTHON PROGRAM TO READ A TEXT FILE AND DISPLAY


THENUMBEROFVOWELS/CONSONANTS/LOWERCASE/UPPERCASECHARACTERS.
AIM:

To write a Python Program to read a text file "Story.txt" and displays the number
ofVowels/Consonants/ Lowercase /Uppercase/characters inthefile.

SOURCECODE:

Result:

Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

13

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:
Story.txt:

***************************************************************************************

14

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:9

DATE:

CREATING PYTHONPROGRAMTODISPLAYSHORTWORDSFROMATEXTFILE

AIM:
To Write a method Disp() in Python, to read the lines from poem.txt and display
thosewords whicharelessthan5characters.

SourceCode:

Result:

Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

Sample

Output:Poem.

txt:

PythonExecutedProgramOutput:

**********************************************************************************

15

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:10

DATE:

CREATINGAPYTHONPROGRAMTOCOPYPARTICULARLINESOFATEXTFILEINTOAN
ANOTHERTEXT FILE
AIM:

Towriteapythonprogramtoreadlinesfromatextfile"Sample.txt"andcopythoselinesintoano
therfilewhicharestartingwithanalphabet'a'or'A'.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SAMPLEOUTPUT:

PythonExecutedProgramoutput:S
ample.txt:

PythonExecutedProgramOutput:

New.txt:

*****************************************************************************************

16

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
11DATE:

CREATINGAPYTHONPROGRAMTOCREATEANDSEARCHRECORDSIN
BINARYFILE

AIM:

TowriteaPythonProgramtoCreatea binary file with roll number and name.Search for


a given roll number and display the name, if not found display appropriatemessage.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

17

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUPUT:

PYTHONPROGRAMEXECUTEDOUTPUT:

*******************************************************************************************

18

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
12DATE:

CREATINGAPYTHONPROGRAMTOCREATEANDUPDATE/
MODIFYRECORDSINBINARY FILE
AIM:

TowriteaPythonProgramtoCreateabinaryfilewithrollnumber,name,markandupdate/
modifythemarkforagivenrollnumber.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

19

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PYTHONPROGRAMEXECUTEDOUTPUT:

**********************************************************************************

20

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
13DATE:

CREATINGAPYTHONPROGRAMTOCREATEANDSEARCHEMPLOYEE’SRECORD
INCSVFILE.

AIM:

TowriteaPythonprogramCreateaCSVfiletostoreEmpno,Name,SalaryandsearchanyEmpnoanddisplayN
ame,Salaryandifnot found displayappropriatemessage.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.
21

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PYTHONPROGRAMEXECUTEDOUTPUT:

******************************************************************************

22

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
14DATE:

CREATINGAPYTHONPROGRAMTOIMPLEMENTSTACKOPERATIONS(LIST)

AIM:
TowriteaPythonprogramtoimplementStackusingalistdata-

structure,toperformthefollowingoperations:

(i) ToPushanobjectcontainingDoc_IDandDoc_nameofdoctorswhospecializein"E
NT"tothestack.
(ii) (ii) ToPoptheobjectsfromthestackanddisplaythem.(iii)
(iv) (iii) Todisplaytheelementsofthestack(afterperformingPUSHorPOP)

SOURCECODE:

23

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SAMPLEOUTPUT:
PythonProgramExecutedOutput:

24

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

****************************************************************************************

25

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
15DATE:

CREATING A PYTHONPROGRAMTO IMPLEMENT STACKOPERATIONS(Dictionary)

AIM:
ToWrite a program, with separate user-defined functions to perform the following
operations:
(i) To Create a function Push(Stk,D) Where Stack is an empty list and D is Dictionary of
Items.fromthisDictionary Push the keys (name of the student) into a stack,
wherethecorrespondingvalue (marks)isgreaterthan70.
(ii) ToCreateaFunctionPop(Stk),whereStkisaStackimplementedbyalistofstudentnames.
Thefunctionreturnstheitems deletedfrom thestack.
(iii) Todisplaytheelementsofthestack(afterperformingPUSHorPOP).
SourceCode:

26

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

Result:

Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SampleOutput:

*********************************************************************************

27

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
16DATE:

CREATINGAPYTHONPROGRAMTOINTEGRATEMYSQLWITHPYTHON(CRE
ATINGDATABASEANDTABLE)
AIM:
To writea Python Program to integrate MYSQL with Python to create Database and Tableto
storethe detailsofemployees.

SourceCode:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

28

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SampleOutput:

*******************************************************************************************************

29

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
17DATE:

CREATINGAPYTHONPROGRAMTOINTEGRATEMYSQLWITHPYTHON

(INSERTING RECORDSANDDISPLAYINGRECORDS)

AIM:

TowriteaPythonProgramtointegrateMYSQLwithPythonbyinsertingrecordstoEmptableand
displaythe records.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

30

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PythonExecutedProgramOutput:

******************************************************************************************************************************************************************************

31

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
188DATE:
CREATINGAPYTHONPROGRAMTOINTEGRATEMYSQLWITHPYTHON

(SEARCHINGANDDISPLAYINGRECORDS)
AIM:

TowriteaPythonProgramtointegrateMYSQLwithPythontosearchanEmployeeusingEMPI
D and display the record if present in already existing table EMP, if not display
theappropriatemessage.

SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

SAMPLEOUTPUT:

PythonExecutedProgramOutput:

32

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

EX.NO:
19DATE:

CREATINGAPYTHONPROGRAMTOINTEGRATEMYSQLWITHPYTHON(UPDATI
NGRECORDS)
AIM:

TowriteaPythonProgramtointegrateMYSQLwithPythontosearchanEmployeeusingEMPI
DandupdatetheSalaryof an employee if present in already existing
tableEMP,ifnotdisplaytheappropriatemessage.
SOURCECODE:

Result:
Thus, the above Python program has been executed and the output is
verifiedsuccessfully.

33

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SAMPLEOUTPUT:

PythonExecutedProgramOutput:

**************************************************************************************************************************************************

34

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SQLCOMMANDSEXERCISE-l
Ex.No:
2ODATE:

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Rollno Name Gender Age Dept DOA Fees


1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) WriteaQuerytoCreateanewdatabaseinthenameof"STUDENTS".

CREATEDATABASESTUDENTS;

(b) WriteaQuerytoOpenthedatabase"STUDENTS".

USESTUDENTS;

(c) WriteaQuerytocreatetheabovetablecalled:"STU"

CREATETABLESTU(ROLLNOINTPRIMARYKEY,NAMEVARCHAR(lO),GENDERV
ARCHAR(3),AGEINT,DEPTVARCHAR(l5),DOADATE,FEESI
NT);

(d) WriteaQuerytolistalltheexistingdatabasenames.

SHOWDATABASES;

(e) WriteaQuerytoListallthetablesthatexistsinthecurrentdatabase.

SHOWTABLES;
Output:

35

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

SQLCOMMANDSEXERCISE-2
Ex.No:
2lDATE:

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Rollno Name Gender Age Dept DOA Fees


1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) WriteaQuerytoinsertalltherowsofabovetableintoInfotable.

INSERTINTOSTUVALUES(l,'Arun','M',24,'COMPUTER','l997-Ol-

lO',l2O);INSERTINTOSTUVALUES(2,'Ankit','M',2l,'HISTORY','l998-O3-

24',2OO);INSERTINTOSTUVALUES(3,'Anu','F',2O,'HINDI','l996-l2-

l2',3OO);INSERTINTOSTUVALUES(4,'Bala','M',l9,NULL,'l999-O7-

Ol',4OO);INSERTINTOSTUVALUES(5,'Charan','M',l8,'HINDI','l997-O6-

27',25O);INSERTINTOSTUVALUES(6,'Deepa','F',l9,'HISTORY','l997-O6-

27',3OO);

INSERTINTOSTUVALUES(7,'Dinesh','M',22,'COMPUTER','l997-O2-

25',2lO);INSERTINTOSTUVALUES(8,'Usha','F',23,NULL,'l997-O7-3l',2OO);

(b) WriteaQuerytodisplayallthedetailsoftheEmployeesfromtheabovetable'STU'.

SELECT*FROMSTU;

Output:

36

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

(c) Writea querytoRollno,Nameand DepartmentofthestudentsfromSTUtable.

SELECTROLLNO,NAME,DEPTFROMSTU;

Output:

(d) Write a QuerytoselectdistinctDepartmentfromSTUtable.

SELECTDISTICT(DEPT)FROMSTU;

Output:

(e) ToshowallinformationaboutstudentsofHistorydepartment.

SELECT*FROMSTUWHEREDEPT='HISTORY';

Output:

********************************************************************************************

37

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

Ex.No:22 SQLCOMMANDSEXERCISE-

3DATE:

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Rollno Name Gender Age Dept DOA Fees


1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) WriteaQuerytolistnameoffemalestudentsinHindiDepartment.

SELECTNAMEFROMSTUWHEREDEPT='HINDI'ANDGENDER='F';

Output:

(b) WriteaQuerytolistnameofthestudentswhoseagesarebetween18to20.

SELECTNAMEFROMSTUWHEREAGEBETWEENl8AND2O;

Output:

38

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

(c) Writea Querytodisplaythenameof thestudents whose nameisstarting with'A'.

SELECTNAMEFROMSTUWHERENAMELIKE'A%';

Output:

(d) Write aquerytolistthenamesof thosestudents whosenamehave secondalphabet'n'intheirnames.

SELECTNAMEFROMSTUWHERENAMELIKE'_N%';

Output:

**********************************************************************************************************

39

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

Ex.No:23 SQLCOMMANDSEXERCISE-4

DATE:

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Rollno Name Gender Age Dept DOA Fees


1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) Writea Querytodeletethedetailsof Rollnumberis8.

DELETEFROMSTUWHEREROLLNO=8;

Output(AfterDeletion):

(b) WriteaQuerytochangethefessofStudentto170whoseRollnumberis1,iftheexistingfessislessthan
130.

UPDATESTUSETFEES=l7OWHEREROLLNO=lANDFEES<l3O;

Output(AfterUpdate):

40

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

(c) WriteaQuerytoadda newcolumnAreaoftypevarcharintableSTU.

ALTERTABLESTUADDAREAVARCHAR(2O);

Output:

(d) WriteaQuerytoDisplayNameofallstudentswhoseAreaContainsNULL.

SELECTNAMEFROMSTUWHEREAREAISNULL;

Output:

(e) WriteaQuerytodeleteAreaColumnfromthetableSTU.

ALTERTABLESTUDROPAREA;

Output:

(f) WriteaQuery to delete tablefrom Database.

DROPTABLESTU;

Output:
*******************************************************************************************

41

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

Ex.No:24 SQLCOMMANDSEXERCISE-
5DATE:

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:
TABLE:UNIFORM

Ucode Uname Ucolor StockDate


1 Shirt White 2021-03-31
2 Pant Black 2020-01-01
3 Skirt Grey 2021-02-18
4 Tie Blue 2019-01-01
5 Socks Blue 2019-03-19
6 Belt Black 2017-12-09

TABLE:COST

Ucode Size Price Company


1 M 500 Raymond
1 L 580 Mattex
2 XL 620 Mattex
2 M 810 Yasin
2 L 940 Raymond
3 M 770 Yasin
3 L 830 Galin
4 S 150 Mattex

(a) ToDisplaytheaverageprice ofallthe UniformofRaymondCompanyfromtableCOST.

SELECTAVG(PRICE)FROMCOSTWHERECOMPANY='RAYMOND';

Output:

(b) Todisplaydetails of alltheUniformintheUniformtable in descending order ofStockdate.

SELECT*FROMUNIFORMORDERBYSTOCKDATEDESC;

Output:

42

Downloaded by DISHON raj ([email protected])


lOMoARcPSD|40449340

(c) ToDisplaymaxpriceandminpriceofeachcompany.

SELECTCOMPANY,MAX(PRICE),MIN(PRICE)FROMCOSTGROUPBYCOMPANY;

Output:

(d) Todisplaythe company where thenumberofuniforms sizeismorethan 2.

SELECTCOMPANY,COUNT(*)FROMCOSTGROUPBYCOMPANYHAVINGCOUNT(*)>2;

Output:

(e) TodisplaytheUcode,Uname,Ucolor,SizeandCompanyoftablesuniformandcost.

SELECTU.UCODE,UNAME,UCOLOR,SIZE,COMPANYFROMUNIFORMU,COSTCWHEREU.UCODE
=C.UCODE;

Output:

*****************************************************************************************

43

Downloaded by DISHON raj ([email protected])

You might also like