Q. Write SQL Commands for the following on the basis of the given table GRADUATE:
Table: GRADUATE
SNO | NAME | STIPEND | SUBJECT | AVERAGE | RANK |
---|---|---|---|---|---|
1 | KARAN | 400 | PHYSICS | 68 | 1 |
2 | RAJ | 450 | CHEMISTRY | 68 | 1 |
3 | DEEP | 300 | MATHS | 62 | 2 |
4 | DIVYA | 350 | CHEMISTRY | 63 | 1 |
5 | GAURAV | 500 | PHYSICS | 70 | 1 |
6 | MANAV | 400 | CHEMISTRY | 55 | 2 |
7 | VARUN | 250 | MATHS | 64 | 1 |
8 | LIZA | 450 | COMPUTER | 68 | 1 |
9 | PUJA | 500 | PHYSICS | 62 | 1 |
10 | NISHA | 300 | COMPUTER | 57 | 2 |
(i) List the names of those students who have obtained rank 1 sorted by NAME
(ii) Display a list of all those names whose AVERAGE is greater than 65.
(iii) Display the names of those students who have opted COMPUTER as a subject with an AVERAGE of more than 60.
(iv) List the names of all the students in alphabetical order.
(v) SELECT * FROM GRADUATE WHERE NAME LIKE "% 1 %";
(vi) SELECT DISTINCT RANK FROM GRADUATE;
Answer =
(i)
Select NAME from GRADUATE order by NAME where RANK = 1 ;
(ii)
Select NAME from GRADUATE where AVERAGE > 65 ;
(iii)
Select NAME from GRADUATE where SUBJECT = “COMPUTER” AVERAGE > 65 ;
(iv)
Select NAME from GRADUATE order by NAME ;
(v)
SNO |
NAME |
STIPEND |
SUBJECT |
AVERAGE |
RANK |
4 |
DIVYA |
350 |
CHEMISTRY |
63 |
1 |
8 |
LIZA |
450 |
COMPUTER |
68 |
1 |
(vi)
RANK |
1 |
2 |
In (v) record of NISHA also mentioned
ReplyDeleteYes
ReplyDeleteGo and Marry now
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )