//Downloaded From www.c4cpp.co.nr//(C)2009.All rights reserved.STRUCTURED QUERY LANGUAGE-1TABLE: SPORTSStudentNo:class Nam...
WRITE THE SQL COMMANDS FOR (1) TO (7) ON THE BASISOF THE TABLE SPORTS1) Display the names of students who have grade ‘C ’i...
VENNA4)Display the games taken up by the students ,whose name starts with ‘A’.SELECT GAME1,GAME2FROM SPORTSWHERE NAME LIKE...
OUTPUTStudentNo:class Name Game 1 Grade 1 Game 2 Grade 214 9 Archana Basketball A Cricket A15 10 Arpith Cricket A Athletic...
STRUCTURED QUERY LANGUAGE-2TABLE:STUDENTNo: Name Stipend Stream Avgmark Grade Class1 Karan 400.00 Medical 78.5 B 12B2 Diva...
WRITE SQL COMMANDS FOR QUESTIONS 1 TO 7 ON THE BASIS OFTABLE STUDENT1)Select all the Nonmedical stream students from STUDE...
OUTPUTROBERTMOHANDIVYAARUNJOHNKARANRUBINADIVAKARSABINAVIKAS4)To count the number of students with grade “A”SELECT COUNT(GR...
1150.00C)SELECT AVG(STIPEND)FROM STUDENT WHERE CLASS=”12A”;OUTPUT475.00D)SELECT COUNT(DISTINCT)OUTPUT10
Upcoming SlideShare
Loading in …5
×

Structured query language

325 views
321 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
325
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Structured query language

  1. 1. //Downloaded From www.c4cpp.co.nr//(C)2009.All rights reserved.STRUCTURED QUERY LANGUAGE-1TABLE: SPORTSStudentNo:class Name Game 1 Grade 1 Game 2 Grade 210 7 Sammer Cricket B Swimming A11 8 Sujith Tennis A Skating C12 7 Kamal Swimming B Football B13 7 Venna Tennis C Tennis A14 9 Archana Basketball A Cricket A15 10 Arpit Cricket A Athletics C
  2. 2. WRITE THE SQL COMMANDS FOR (1) TO (7) ON THE BASISOF THE TABLE SPORTS1) Display the names of students who have grade ‘C ’in either Game 1or Game 2 or both.SELECT NAMEFROM SPORTSWHERE GRADE 1 =’C’. OR. GRADE 2 = ‘C’;OUTPUTNAMESUJITHVENNAARPIT2)Display the number of students getting grade ‘A’ in cricket.SELECT COUNT (*) FROM SPORTSWHERE GRADE1 =”A” .AND. GAME2=”CRICKET” .OR. GRADE2 =”A”.AND. GAME2=”CRICKET”;OUTPUTCOUNT(*)23)Display the names of the students who have same game for both Game 1and Game 2.SELECT NAME FROM SPORTSWHERE GAME 1 =GAME 2;OUTPUTNAME
  3. 3. VENNA4)Display the games taken up by the students ,whose name starts with ‘A’.SELECT GAME1,GAME2FROM SPORTSWHERE NAME LIKE (”A%”);OUTPUTGAME1 GAME2BASKETBALL CRICKETCRICKET ATHELETICS5) Add a new column named ‘Marks’.ALTER TABLE SPORTSADD MARKS FLOAT (6, 2);OUTPUTONE COLUMN ADDED6)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 =200WHERE GRADE1<=”B” AND. GRADE2<=”B”;OUTPUT3 RECORDS UPDATED7)Arrange the whole table in the alphabetical order by name.SELECT*FROM SPORTSORDER BY NAME;
  4. 4. OUTPUTStudentNo:class Name Game 1 Grade 1 Game 2 Grade 214 9 Archana Basketball A Cricket A15 10 Arpith Cricket A Athletics C12 7 Kamal Swimming B Football B10 7 Sammer Cricket B Swimming A11 8 Sujith Tennis A Skating C13 7 Venna Tennis C Tennis A
  5. 5. STRUCTURED QUERY LANGUAGE-2TABLE:STUDENTNo: Name Stipend Stream Avgmark Grade Class1 Karan 400.00 Medical 78.5 B 12B2 Divakar 450.00 Commerce 89.2 A 11C3 Divya 300.00 Commerce 68.6 C 12C4 Arun 350.00 Humanities 73.1 B 12C5 Sabina 500.00 Nonmedical 90.6 A 11A6 John 400.00 Medical 75.4 B 12B7 Robert 250.00 Humanities 64.4 C 11A8 Rubina 450.00 Nonmedical 88.5 A 12A9 Vikas 500.00 Nonmedical 92.0 A 12A10 Mohan 300.00 Commerce 67.5 C 12C
  6. 6. WRITE SQL COMMANDS FOR QUESTIONS 1 TO 7 ON THE BASIS OFTABLE STUDENT1)Select all the Nonmedical stream students from STUDENT.SELECT NAMEFROM STUDENTWHERE STREAM=’NONMEDICAL’;OUTPUTNAME:SABINARUBINAVIKAS2)list the names of those students who are in class 12 sorted by stipendSELECT NAME,STIPEND FROM STUDENTWHERE CLASS=’12’ORDER BY STIPEND;OUTPUTNAME STIPENDDIVYA 300.00MOHAN 300.00ARUN 350.00KARAN 400.00JOHN 400.00RUBINA 450.00VIKAS 500.003)list all students sorted by avgmark in descending orderSELECT NAME FROM STUDENTORDER BY AVGMARK DESC;
  7. 7. OUTPUTROBERTMOHANDIVYAARUNJOHNKARANRUBINADIVAKARSABINAVIKAS4)To count the number of students with grade “A”SELECT COUNT(GRADE)FROM STUDENTWHERE GRADE=”A”;OUTPUT45)to insert a new student in the table anf fill the columns with some valuesINSERT INTO STUDENT VALUES(11,”MANISHA”,300.00,”NONMEDICAL”,72.5,”B”,12C);OUTPUTONE ROW ADDED6)give the output of the following SQL statement:A)SELECT MIN(AVGMARK)FROM STUDENTWHERE AVGMARK<75;OUTPUT64.4B)SELECT SUM(STIPEND) FROM STUDENT WHERE GRADE=”B”OUTPUT
  8. 8. 1150.00C)SELECT AVG(STIPEND)FROM STUDENT WHERE CLASS=”12A”;OUTPUT475.00D)SELECT COUNT(DISTINCT)OUTPUT10

×