Q. Write SQL commands for the following on the basis of given table SPORTS:
StudentNo | Class | Name | Game1 | Grade1 | Game2 | Grade2 |
---|---|---|---|---|---|---|
10 | 7 | Sameer | Cricket | B | Swimming | A |
11 | 8 | Sujit | Tennis | A | Skating | C |
12 | 7 | Kamal | Swimming | B | Football | B |
13 | 7 | Veena | Tennis | C | Tennis | A |
14 | 9 | Archana | Basketball | A | Cricket | A |
15 | 10 | Arpit | Cricket | A | Athletics | C |
(a) Display the names of the students who have grade 'A' in either Game1 or
Game2 or both.
(b) Display the number of students having game
'Cricket'.
(c) Display the names of students who have the same game for
both Game1 and Game2.
(d) Display the games taken by the students whose
name starts with 'A'.
(e) Give the output of the following sql
statements:
(i) select count(*) from SPORTS;
(ii) select distinct
Class from SPORTS;
(iii) select max(Class) from STUDENT;
(iv)
select count(*) from SPORTS group by Game1;
Answer :-
(a) Select name from sportsWhere grade1 =
"c" or grade2 = "c" ;
(b) Select count(*) from student where game =
'Cricket' or game2 = 'Cricket' ;
(c) Select name from sports Where game1
= game2 ;
(d) Select game1 , game2 from sports Where name like “A%”
;
(e)
(i)
count(*) |
---|
6 |
(ii)
distinct Class |
---|
7 |
8 |
9 |
10 |
(iii)
max(Class) |
---|
10 |
(iv)
count(*) |
---|
2 |
2 |
1 |
1 |
it is wrong it should be like Where grades = 'c' or Grades2 = 'c'
ReplyDeleteyup
DeleteYes you are right.
DeleteIn grade 1 is tennis while in grade 2 are skating and athletics....
ReplyDeleteOn game 1 and game 2 they have both swimming....
In game 1 choose swimming and I'm game 2 i choose athletics
Do you want query of "In game 1 choose swimming and I'm game 2 i choose athletics" then answer is
DeleteSelect name from sports
Where game1 = "swimming"game2="athletics" ;
Select substring(game2, 2,4) from sports where grade 2=''a''
ReplyDeleteIn 2nd answer there must be And in place of or
ReplyDeleteNo, Please read quetion carefully.
DeletePlease tell assign a value 200 marks for all those who who are getting grade B or above in GAME
ReplyDeleteits sort of wrong
ReplyDeletechahe koi mujhe jangli kahe..... kehne ko ji kehta rahe.....hum scienceke toofano me ghire hai hum kya kare...
ReplyDeleteCan you explain the (iv) question from A sub division
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )