Professional Documents
Culture Documents
Kendriya Vidyalaya
Kendriya Vidyalaya
GHAZIABAD
COMPUTER SCIENCE-(083)
PRACTICAL FILE
TERM-2 [2021-22]
Output 2:-
Question 1:- Create a student table with the student id, name,
city and marks as attributes where the student id is the primary
key.
QUERY:-
mysql-> create table students
-> (sid char(5),
-> name char(15),
-> city char(20),
-> marks decimal(5,2));
Question 2:- Write a query to insert the details of a new
student(„S5‟,‟KUINKA‟,‟MORENA‟,53.6) in the above table.
QUERY:-
mysql> INSERT INTO student
-> values('s5','kuinka','morena',53.6);
OUTPUT 3:-
OUTPUT 4:-
Question 3:- Write a query to delete the details of a student in
the above table.
QUERY:-
mysql> delete from students
-> where sid='s2';
Question 4:- Write a query to display the details of the students
with marks more than 80.
QUERY:-
mysql> select*from students
-> where marks>80;
OUTPUT 5:-
OUTPUT 6:-
Question 5:- Write a query to find the min, max, sum, and
average of the marks in a students table.
QUERY:-
mysql> select min(marks),max(marks),sum(marks),avg(marks)
from students;
Question 6:- Write a query to find the total number of students
from each city in the table Customer (SID, Name, City) using
group by.
QUERY:-
mysql> select city,count(*) from students group by city;
OUTPUT 7:-
OUTPUT 8:-
Question 7:- Write a query to display the (student ID
marks) table in descending order of the marks.
QUERY:-
mysql> select sid, marks from students order by
marks desc;
Question 8:- Write a query to display the number of students
with same class.
QUERY:-
mysql> select class,count(*) from students group by class;
OUTPUT 9:
OUTPUT 10:-
Question 9:- Write a query to display the class where the
number of student is less than 3 from students table.
QUERY:-
mysql> select class,count(*) from students group by class
having count(*) >3;
Question 10:- Write a query to display the Sum, Average,
Highest and Lowest marks of the students grouped by class.
QUERY:-
mysql>selectClass,sum(Marks),avg(Marks) ,max(Marks),
min(Marks) from students Group by class;
OUTPUT 11:-
OUTPUT 12:-
OUTPUT 13:-
Question 11:- Write a query to display the number of students
city wise.
QUERY:-
mysql> select city,count(*) from students group by city;
Question 12:- Write a query to display names “MR. OBAMA”
and “MS. Gandhi‟ into lower case.
QUERY:-
mysql> select lcase('MR. OBAMA'),Lcase('MS. Gandhi');
Question 13:- Write a query to display 4 characters extracted
from 3rd left character onwards from string “ABCDEFG”.
QUERY:-
mysql> select substr('ABCDEFG',3);
OUTPUT 14:-
OUTPUT 15:-
Question 14:- Write a query to count the number of characters
are there in string “CANDIDATE”.
QUERY:-
mysql> select length("CANDIDATE");
Question 15:- Write a query to delete the details of a student
(”KUINKA”) from the students table.
QUERY:-
mysql> delete from students where name="kuinka";