0% found this document useful (0 votes)
4 views1 page

Assignment 14

A MySQL database named 'assignment_14' is created with a table 'Student' that includes student IDs, names, and marks. Six records are inserted into the 'Student' table, and a stored procedure 'MarkGreat70' is created to count and display students with marks greater than 70. When the procedure is called, it confirms a total of 6 rows and lists 5 students who have marks above 70.

Uploaded by

Mrinmoy Pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Assignment 14

A MySQL database named 'assignment_14' is created with a table 'Student' that includes student IDs, names, and marks. Six records are inserted into the 'Student' table, and a stored procedure 'MarkGreat70' is created to count and display students with marks greater than 70. When the procedure is called, it confirms a total of 6 rows and lists 5 students who have marks above 70.

Uploaded by

Mrinmoy Pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

mysql> use assignment_14;

Database changed
mysql>
mysql> CREATE TABLE Student (
-> student_id INT PRIMARY KEY,
-> student_name VARCHAR(255),
-> marks INT
-> );
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Student (student_id, student_name, marks)


-> VALUES
-> (1, 'Rahul Kumar', 85),
-> (2, 'Priya Sharma', 78),
-> (3, 'Amit Patel', 92),
-> (4, 'Sneha Gupta', 70),
-> (5, 'Deepak Singh', 88),
-> (6, 'Pooja Verma', 75);
Query OK, 6 rows affected (0.00 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> DELIMITER //
mysql> CREATE PROCEDURE MarkGreat70()
-> BEGIN
-> DECLARE total_rows INT;
-> SELECT COUNT(*) INTO total_rows FROM Student;
-> SELECT CONCAT('Total rows in Student table: ', total_rows);
-> SELECT student_id, student_name, marks
-> FROM Student
-> WHERE marks > 70;
-> END //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> CALL MarkGreat70();
+-----------------------------------------------------+
| CONCAT('Total rows in Student table: ', total_rows) |
+-----------------------------------------------------+
| Total rows in Student table: 6 |
+-----------------------------------------------------+
1 row in set (0.00 sec)

+------------+--------------+-------+
| student_id | student_name | marks |
+------------+--------------+-------+
| 1 | Rahul Kumar | 85 |
| 2 | Priya Sharma | 78 |
| 3 | Amit Patel | 92 |
| 5 | Deepak Singh | 88 |
| 6 | Pooja Verma | 75 |
+------------+--------------+-------+
5 rows in set (0.00 sec)

Query OK, 0 rows affected (0.02 sec)

You might also like