0% found this document useful (0 votes)
8 views

Cs Term 2 Practical File

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Cs Term 2 Practical File

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

CS PRACTICAL FILE

TERM 2

ANIKET AGARWAL
CLASS XII-C
ROLL NO-5
SQL
Create Table:

(b) To show all information of students where capacity is more than the number of
students in order of Rtn.

(c) To show Area_covered for buses covering more than 20 km, but charges less
than 80000.

(d) To show transporter-wise total number of students traveling.

(e) To show Rtn, Area_covered, and average cost per student for all routes
where average cost per student is Charges / No_of_students.
(f) Add a new record with the following data:

(11, "Moti Bagh", 35, 32, 10, "Kisan Tours", 35000)

(g) Give the output considering the original relation as given:

(i) Select sum(distance) from SchoolBus where Transporter = 'Yadav


Travels':

(ii) Select the minimum No_of_students from SchoolBus:

(iii) Select the average Charges from SchoolBus where Transporter = 'Anand
Travels':

(iv) Select distinct Transporter from SchoolBus:


Creating the GRADUATE Table

(a) List the names of those students who have obtained DIV 1 sorted by NAME.

(b) Display a report, listing NAME, STIPEND, SUBJECT, and amount of stipend
received in a year (assuming STIPEND is paid every month).

(c) To count the number of students who are either PHYSICS or COMPUTER Sc.
graduates.

(d) To insert a new row in the GRADUATE table:

(e) Give the output of the following SQL statements based on the GRADUATE table:

(i) Select MIN(AVERAGE) from GRADUATE where SUBJECT = "PHYSICS";


(ii) Select SUM(STIPEND) from GRADUATE WHERE DIV = 'II';

(iii) Select AVG(STIPEND) from GRADUATE where AVERAGE >= 65;

(iv) Select COUNT(distinct SUBJECT) from GRADUATE;

(f) Assume there is one more table GUIDE in the database:

Table: GUIDE

(g) What will be the output of the following query:


SELECT NAME, ADVISOR FROM GRADUATE, GUIDE WHERE SUBJECT =
MAINAREA;
Creating the ACTIVITY and COACH Tables:

(a) Display the names of all the activities with their Acodes in descending order.

(b) Display the sum of PrizeMoney for the activities played in each of the
stadiums separately.

(c) Display the coach’s name and Acodes in ascending order of Acode from the
table COACH.
(d) Display the content of the Activity table whose ScheduleDate is earlier than
01/01/2004 in ascending order of ParticipantsNum.

(e) Display the names of coaches who are not associated with any activity at all.

(f) Display the names of activities and their corresponding coach names.

SQL Query Outputs:


(i) SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY;

(ii) SELECT Max(ScheduleDate), MIN(ScheduleDate) FROM ACTIVITY;


(iii) SELECT COUNT(*) FROM COACH;

(iv) SELECT Name, ActivityName FROM activity A, COACH C WHERE A.Acode = C.Acode
AND A.ParticipantsNum = 10;

(v) SELECT DISTINCT Acode FROM COACH;


Assume the following file (sample.txt):
The quick brown fox
The lazy dog
A fast runner is always ahead
The sun rises in the east
Let's assume the file Address.TXT contains:

Example Interaction:
Content of NAdd.TXT after replacement:

You might also like