MySQL
1: To create the given table and name as stu1 and insert values:
mysql> create table stu1(sno int, name varchar(20), stipend int, stream
varchar(30), avgmarks float(5,2), grade char(1), class varchar(5));
mysql> insert into stu1 values(1, ‘karan’ ,400, ‘medical’, 78.5, ‘B’, ‘12B’);
(adding some more values into this table, let the table be as shown below)
2: To display name and avgmarks in descending order:
mysql> select name, avgmarks from stu1 order by avgmarks desc;
3: To display the minimum, maximum and average marks:
mysql> select min(avgmarks) from stu1;
mysql> select max(avgmarks) from stu1;
mysql>select avg(avgmarks) from stu1;
4: To display name and stipend, also add 10 marks in stipend whose
stipend<300:
mysql>select name, stipend+10 ‘new stipend’ from stu1 where
stipend<400;
5: To count the number of students in each stream:
mysql>select count(name),stream from stu1 group by stream;
6: Pattern matching (like operator):
mysql> select name, stream from stu1 where name like “d%”;
7: To update the a column with given condition:
mysql> update stu1 set grade='C' where sno=4;
8: To update one whole row:
mysql>update stu1 set stipend=stipend+10;
9.Group By clause:
Query:
10.Having clause:
Query: