Professional Documents
Culture Documents
TABLE: SPORTS
Student No: 10 11 12 13 14 15 class 7 8 7 7 9 10 Name Sammer Sujith Kamal Venna Archana Arpit Game 1 Cricket Tennis Swimming Tennis Basketball Cricket Grade 1 B A B C A A Game 2 Swimming Skating Football Tennis Cricket Athletics Grade 2 A C B A A C
WRITE THE SQL COMMANDS FOR (1) TO (7) ON THE BASIS OF THE TABLE SPORTS 1) Display the names of students who have grade C in or Game 2 or both. SELECT NAME FROM SPORTS WHERE GRADE 1 =C. OR. GRADE 2 = C; OUTPUT NAME SUJITH VENNA ARPIT 2)Display the number of students getting grade A in cricket. SELECT COUNT (*) FROM SPORTS WHERE GRADE1 =A .AND. GAME2=CRICKET .OR. GRADE2 =A .AND. GAME2=CRICKET; OUTPUT COUNT(*) 2 3)Display the names of the students who have same game for both Game 1 and Game 2. SELECT NAME FROM SPORTS WHERE GAME 1 =GAME 2; OUTPUT NAME VENNA 4)Display the games taken up by the students ,whose name starts with A. either Game 1
5) Add a new column named Marks. ALTER TABLE SPORTS ADD MARKS FLOAT (6, 2); OUTPUT ONE COLUMN ADDED 6)Assign a value 200 for Marks for all those who are getting grade B or grade A in both Game1 and Game2. UPDATE SPORTS SET MARKS =200 WHERE GRADE1<=B AND. GRADE2<=B; OUTPUT 3 RECORDS UPDATED 7)Arrange the whole table in the alphabetical order by name. SELECT*FROM SPORTS ORDER BY NAME;
OUTPUT
Student No: 14 15 12 10 11 13
class 9 10 7 7 8 7
Grade 1 A A B B A C
Grade 2 A C B A C A
TABLE:STUDENT
No: 1 2 3 4 5 6 7 8 9 10 Name Karan Divakar Divya Arun Sabina John Robert Rubina Vikas Mohan Stipend 400.00 450.00 300.00 350.00 500.00 400.00 250.00 450.00 500.00 300.00 Stream Medical Commerce Commerce Humanities Nonmedical Medical Humanities Nonmedical Nonmedical Commerce Avgmark 78.5 89.2 68.6 73.1 90.6 75.4 64.4 88.5 92.0 67.5 Grade B A C B A B C A A C Class 12B 11C 12C 12C 11A 12B 11A 12A 12A 12C
WRITE SQL COMMANDS FOR QUESTIONS 1 TO 7 ON THE BASIS OF TABLE STUDENT 1)Select all the Nonmedical stream students from STUDENT.
OUTPUT NAME: SABINA RUBINA VIKAS 2)list the names of those students who are in class 12 sorted by stipend SELECT NAME,STIPEND FROM STUDENT WHERE CLASS=12 ORDER BY STIPEND; OUTPUT NAME DIVYA MOHAN ARUN KARAN JOHN RUBINA VIKAS STIPEND 300.00 300.00 350.00 400.00 400.00 450.00 500.00
3)list all students sorted by avgmark in descending order SELECT NAME FROM STUDENT ORDER BY AVGMARK DESC; OUTPUT ROBERT MOHAN DIVYA ARUN JOHN
4)To count the number of students with grade A SELECT COUNT(GRADE) FROM STUDENT WHERE GRADE=A; OUTPUT 4 5)to insert a new student in the table anf fill the columns with some values INSERT INTO STUDENT VALUES (11,MANISHA,300.00,NONMEDICAL,72.5,B,12C); OUTPUT ONE ROW ADDED 6)give the output of the following SQL statement:
A)SELECT MIN(AVGMARK) FROM STUDENT WHERE AVGMARK<75; OUTPUT 64.4 B)SELECT SUM(STIPEND) FROM STUDENT WHERE GRADE=B OUTPUT 1150.00 C)SELECT AVG(STIPEND)FROM STUDENT WHERE CLASS=12A; OUTPUT 475.00 D)SELECT COUNT(DISTINCT) OUTPUT
10