Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

SQL

Uploaded by

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

SQL

Uploaded by

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

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%';

8.Write 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';

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

You might also like