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

SQL PROGRAM 2

The document outlines SQL commands to create and manage a STUDENT table, including inserting student records with scores in six subjects. It calculates the total score and percentage marks, determines pass or fail status based on subject scores, and retrieves various queries related to student results. Additionally, it includes commands to alter the table structure and display the data in different formats.

Uploaded by

alphy186
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 PROGRAM 2

The document outlines SQL commands to create and manage a STUDENT table, including inserting student records with scores in six subjects. It calculates the total score and percentage marks, determines pass or fail status based on subject scores, and retrieves various queries related to student results. Additionally, it includes commands to alter the table structure and display the data in different formats.

Uploaded by

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

CREATE TABLE STUDENT (SId INT(4),NAME VARCHAR(25),Sub1 INT(3),Sub2 INT(3),Sub3

INT(3),Sub4 INT(3),Sub5 INT(3),Sub6 INT(3));


SHOW TABLES;
INSERT INTO STUDENT VALUES(2001,'RAJESH',45,60,79,80,99,100);
INSERT INTO STUDENT VALUES(2002,'RAMESH',67,60,56,90,29,19);
INSERT INTO STUDENT VALUES(2003,'SHASHI',54,70,89,50,90,29);
INSERT INTO STUDENT VALUES(2004,'SHAKSHI',56,49,56,42,61,18);
INSERT INTO STUDENT VALUES(2005,'CHETAN',15,28,35,39,17,31);
INSERT INTO STUDENT VALUES(2006,'GEETHA',95,70,69,50,49,90);
INSERT INTO STUDENT VALUES(2007,'SAVITHA',05,0,19,40,39,10);
INSERT INTO STUDENT VALUES(2008,'AMOGH',26,57,70,55,95,16);
INSERT INTO STUDENT VALUES(2009,'RAKESH',25,80,74,23,99,49);
INSERT INTO STUDENT VALUES(2010,'SINDHU',45,67,56,40,63,53);
SELECT * FROM STUDENT;
DESCRIBE STUDENT;
ALTER TABLE STUDENT ADD(TOTAL INT(3),PMARKS DECIMAL(6,2));
DESCRIBE STUDENT;
UPDATE STUDENT SET TOTAL=Sub1+Sub2+Sub3+Sub4+Sub5+Sub6;
UPDATE STUDENT SET PMARKS=(TOTAL/600)*100;
SELECT * FROM STUDENT;
ALTER TABLE STUDENT ADD(RESULT VARCHAR(5));
DESCRIBE STUDENT;
UPDATE STUDENT SET RESULT="PASS" WHERE Sub1 >=35 AND Sub2 >=35 AND Sub3 >=35 AND
Sub4 >=35 AND Sub5 >=35 AND Sub6 >=35;
UPDATE STUDENT SET RESULT="FAIL" WHERE Sub1 <35 OR Sub2 <35 OR Sub3 <35 OR Sub4 <35
OR Sub5 <35 OR Sub6 <35;
SELECT * FROM STUDENT;
SELECT * FROM STUDENT;
SELECT SId,NAME FROM STUDENT;
SELECT * FROM STUDENT WHERE RESULT="PASS";
SELECT * FROM STUDENT WHERE RESULT="FAIL";
SELECT COUNT(*) FROM STUDENT WHERE RESULT="PASS";
SELECT COUNT(*) FROM STUDENT WHERE RESULT="FAIL";
SELECT * FROM STUDENT WHERE PMARKS>=60;
SELECT * FROM STUDENT ORDER BY SID;

You might also like