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

SQL Commands for Student Class Management

Uploaded by

sanaafreen1407
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)
15 views2 pages

SQL Commands for Student Class Management

Uploaded by

sanaafreen1407
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

1.

CREATE TABLE CLASS(


ROLLNO INTEGER PRIMARY KEY,
NAME VARCHAR(20),
STIPEND INTEGER,
SUBJECT VARCHAR(20),
AVGMARK INTEGER,
GRADE CHAR(1));

INSERT INTO CLASS VALUES(1,’VIKAS’,1400,’HUMANITIES’,78,’B’);

1. Display the table.


SELECT *FROM CLASS;

2. Arrange the records of class namewise.


Ans: SELECT *FROM CLASS ORDER BY NAME ;

3. List the records whose grade is B or C.


Ans: SELECT *FROM CLASS WHERE GRADE='B' OR GRADE='C';

4. Display name,ROLLNO AND SUBJECT whose average marks in between 75 and 100.
ANs: SELECT NAME, ROLLNO, SUBJECT FROM CLASS WHERE AVGMARK
BETWEEN 75 AND 100;

5. Display records of those students who secured marks more than 80 from non-medical.
Ans: SELECT *FROM CLASS WHERE AVGMARK>80 AND SUBJECT='NON-
MEDICAL';

6. Write SQL command to display records of students whose alphabet begins with ‘v’.
Ans: SELECT *FROM CLASS WHERE NAME LIKE'%V%';

7. Write SQL command to display records of students whose second alphabet is ‘A’.
Ans: SELECT *FROM CLASS WHERE NAME LIKE'_A%';

[Link] SQL command to Update the subject of rollno 4 from Non-medical to BCA.
UPDATE CLASS SET SUBJECT='BCA' WHERE ROLLNO='4';

9. Write SQL command to Delete the record of the student having rollno 2.
Ans : DELETE FROM CLASS WHERE ROLLNO='2';

10. Insert the new row with the following data. (6,'JACK',2800,'HUMANITIES',98,'A')
Ans: INSERT INTO CLASS VALUES
(6,'JACK',2800,'HUMANITIES',98,'A');

11. To list Name,Subject for all the students whose average mark is less than 70.
Ans: SELECT NAME, SUBJECT FROM CLASS WHERE AVGMARK<70;
12. To display name, subject,rollno, average mark in descending order of average marks from
the CLASS table.
Ans: SELECT NAME,SUBJECT,AVGMARK FROM CLASS ORDER BY AVGMARK
DESC;

13. Write a Update the stipend of the student to 1250, whose rollno is 3.
Ans: UPDATE CLASS SET STIPEND='1250' WHERE ROLLNO='3';

******************************

Common questions

Powered by AI

To update a student's stipend to a new value based on their roll number, you can use the following SQL command: UPDATE CLASS SET STIPEND='new_value' WHERE ROLLNO='specific_roll_number' . For roll number 3, the command is UPDATE CLASS SET STIPEND='1250' WHERE ROLLNO='3'.

To arrange the CLASS table records in alphabetical order by student names, the SQL command is: SELECT *FROM CLASS ORDER BY NAME .

To update a student's subject in the CLASS table when the roll number is known, use the UPDATE statement. For example, to change the subject to 'BCA' for roll number 4, the SQL command is: UPDATE CLASS SET SUBJECT='BCA' WHERE ROLLNO='4' .

The query to show students' names and subjects with grades 'B' or 'C' is: SELECT *FROM CLASS WHERE GRADE='B' OR GRADE='C' . Filtering by grades can be significant for identifying students who are meeting certain performance thresholds, allowing educators to assess the effectiveness of teaching methods, provide additional support, or recognize achievements.

The command to retrieve students' names and roll numbers with average marks between 75 and 100 is: SELECT NAME, ROLLNO, SUBJECT FROM CLASS WHERE AVGMARK BETWEEN 75 AND 100 . This range can be useful for educators as it identifies students performing above average, allowing them to offer advanced opportunities or further motivation to maintain or improve performance.

To delete a student's record based on their roll number in the CLASS table, use the SQL DELETE statement. If the roll number is 2, the command is: DELETE FROM CLASS WHERE ROLLNO='2' .

To list the records of students whose second alphabet in their name is 'A', use the SQL LIKE pattern matching operator. The specific command is: SELECT *FROM CLASS WHERE NAME LIKE '_A%' .

Inserting a new student record into the CLASS table involves using the INSERT INTO statement. For example, to insert the following record: (6, 'JACK', 2800, 'HUMANITIES', 98, 'A'), you would use the SQL command: INSERT INTO CLASS VALUES (6, 'JACK', 2800, 'HUMANITIES', 98, 'A').

To display records of students securing marks more than 80 from a specific subject, such as 'NON-MEDICAL', the SQL statement is: SELECT *FROM CLASS WHERE AVGMARK>80 AND SUBJECT='NON-MEDICAL' .

To display the names and subjects of students with an average mark below 70, the SQL query to use is: SELECT NAME, SUBJECT FROM CLASS WHERE AVGMARK<70 .

You might also like