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

sql 1

The document outlines a series of SQL queries related to a 'student' table, including creation, insertion of records, selection of data, and various aggregations. It demonstrates operations such as filtering students by marks, retrieving maximum and minimum marks, and deleting records based on conditions. The final state of the table reflects the successful execution of these queries, with updated student records and aggregate values.

Uploaded by

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

sql 1

The document outlines a series of SQL queries related to a 'student' table, including creation, insertion of records, selection of data, and various aggregations. It demonstrates operations such as filtering students by marks, retrieving maximum and minimum marks, and deleting records based on conditions. The final state of the table reflects the successful execution of these queries, with updated student records and aggregate values.

Uploaded by

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

query:1

create table student(


id int primary key,
name varchar(20),
marks int);

output:Query OK, 0 rows affected (0.02 sec)

query:2

insert into student values


(101,"chintu",80),
(102,"charmi",86),
(103,"shivani",95),
(104,"bharthi",98);

output:Query OK, 4 rows affected (0.01 sec)


Records: 4 Duplicates: 0 Warnings: 0

query:3

select*from student;

output:+-----+---------+-------+
| id | name | marks |
+-----+---------+--------+
| 101 | chintu | 80 |
| 102 | charmi | 86 |
| 103 | shivani | 95 |
|104 | bharthi | 98 |
+------+---------+--------+
4 rows in set (0.00 sec)

query4:
select*from student where marks>84;

output:
+-----+----------+--------+
| id | name | marks |
+-----+----------+--------+
| 102 |charmi | 86 |
| 103 | shivani | 95 |
| 104 | bharthi | 98 |
+-----+----------+--------+

query5:
select max(marks),min(marks) from student;

output: +--------------+--------------+
| max(marks) | min(marks) |
+--------------+--------------+
| 98 | 80 |
+---------------+--------------+

query6:
select*from student order by marks desc;
output:

+------+---------+--------+
| id | name | marks |
+------+---------+--------+
| 104 | bharthi | 98 |
| 103 | shivani | 95 |
| 102 | charmi | 86 |
| 101 | chintu | 80 |
+-------+--------+--------+
4 rows in set (0.00 sec)

query7:
select ucase(name) from student;

output:
+----------------+
| ucase(name) |
+----------------+
| CHINTU |
| CHARMI |
| SHIVANI |
| BHARTHI |
+----------------+
4 rows in set (0.00 sec)

query8: select count(id) from student;

output: +-----------+
| count(id) |
+-----------+
| 4 |
+-----------+

query9: select sum(marks) from student;

output:
+--------------+
| sum(marks) |
+--------------+
| 359 |
+--------------+
1 row in set (0.00 sec)

query10: delete from student where marks<85;

output: Query OK, 1 row affected (0.01 sec)

You might also like