0% found this document useful (0 votes)
5 views2 pages

1

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)
5 views2 pages

1

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/ 2

mysql> select min(stu_marks), max(stu_marks), sum(stu_marks),

avg(stu_marks) from student;


+----------------+----------------+----------------+----------------
+
| min(stu_marks) | max(stu_marks) | sum(stu_marks) | avg(stu_marks)
|
+----------------+----------------+----------------+----------------
+
| 75 | 93 | 525 | 87.5000

mysql> SELECT country, COUNT(customer_ID) AS total_customers from


customer group by country;
+---------+-----------------+
| country | total_customers |
+---------+-----------------+
| USA | 7 |
| UK | 3 |
| India | 3 |
| Germany | 3 |
| Canada | 4 |
+---------+-----------------+
5 rows in set (0.01 sec)

mysql> select stu_id,stu_marks from student order by stu_marks desc;


+--------+-----------+
| stu_id | stu_marks |
+--------+-----------+
| S0001 | 93 |
| S0002 | 92 |
| S0005 | 90 |
| S0004 | 89 |
| S0006 | 86 |
| S0007 | 75 |
+--------+-----------+
6 rows in set (0.00 sec)

mysql> delete from student where stu_id="s0003";


Query OK, 1 row affected (0.02 sec)
mysql> create table student (stu_id char(5) primary key , stu_name
varchar(25),stu_marks int(3));
Query OK, 0 rows affected, 1 warning (0.04 sec)
mysql> desc student;
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| stu_id | char(5) | NO | PRI | NULL | |
| stu_name | varchar(25) | YES | | NULL | |
| stu_marks | int | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)

mysql> insert into student values("S0007","Karthik",75);


Query OK, 1 row affected (0.01 sec)

mysql> select * from student;


+--------+-----------+-----------+
| stu_id | stu_name | stu_marks |
+--------+-----------+-----------+
| S0001 | Kinjal | 93 |
| S0002 | Sonal | 92 |
| S0003 | Kirti | 96 |
| S0004 | Prachi | 89 |
| S0005 | Saubhagya | 90 |
| S0006 | Afaf | 86 |
| S0007 | Karthik | 75 |
+--------+-----------+-----------+
7 rows in set (0.00 sec)

mysql> select * from student where stu_marks>80;


+--------+-----------+-----------+
| stu_id | stu_name | stu_marks |
+--------+-----------+-----------+
| S0001 | Kinjal | 93 |
| S0002 | Sonal | 92 |
| S0004 | Prachi | 89 |
| S0005 | Saubhagya | 90 |
| S0006 | Afaf | 86 |
+--------+-----------+-----------+
5 rows in set (0.00 sec)

You might also like