[Assignments] Simple Queries in SQL — Chapter 12 Assignments (Q/A)
Table of Contents
18. Write SQL commands for the following on the basis of given table GRADUATE:
NO | NAME | STIPEND | SUBJECT | AVERAGE | RANK |
---|---|---|---|---|---|
1 | KARAN | 400 | PHYSICS | 68 | 1 |
2 | DIVAKAR | 450 | COMPUTER SC | 68 | 1 |
3 | DIVYA | 300 | CHEMISTRY | 62 | 2 |
4 | ARUN | 350 | PHYSICS | 63 | 1 |
5 | SABINA | 500 | MATHEMATICS | 70 | 1 |
6 | JOHN | 400 | CHEMISTRY | 55 | 2 |
7 | ROBERT | 250 | PHYSICS | 64 | 1 |
8 | RUBINA | 450 | MATHEMATICS | 68 | 1 |
9 | VIKAS | 500 | COMPUTER SC | 62 | 1 |
10 | MOHAN | 300 | MATHEMATICS | 57 | 2 |
(a) List the names of those students who have obtained Rank 1 sorted by NAME.
(b) Display a report listing NAME, STIPEND, SUBJECT and amount of stipend received in a year assuming that the STIPEND is paid every month.
Solution:
SELECT NAME FROM GRADUATE
WHERE RANK = 1
ORDER BY NAME ;SELECT NAME, STIPEND, SUBJECT, STIPEND*12 AS 'STIPEND PER YEAR'
FROM GRADUATE ;