[Assignments] Simple Queries in SQL — Chapter 12 Assignments (Q/A)
Table of Contents
14. Write SQL commands for the following on the basis of given table STUDENT1:
No. | Name | Stipend | Stream | AvgMark | Grade | Class |
---|---|---|---|---|---|---|
1 | Karan | 400.00 | Medical | 78.5 | B | 12B |
2 | Divakar | 450.00 | Commerce | 89.2 | A | 11C |
3 | Divya | 300.00 | Commerce | 68.6 | C | 12C |
4 | Arun | 350.00 | Humanities | 73.1 | B | 12C |
5 | Sabina | 500.00 | Nonmedical | 90.6 | A | 11A |
6 | John | 400.00 | Medical | 75.4 | B | 12B |
7 | Robert | 250.00 | Humanities | 64.4 | C | 11A |
8 | Rubina | 450.00 | Nonmedical | 88.5 | A | 12A |
9 | Vikas | 500.00 | Nonmedical | 92.0 | A | 12A |
10 | Mohan | 300.00 | Commerce | 67.5 | C | 12C |
- Select all the Nonmedical stream students from STUDENT1.
- List the names of those students who are in class 12 sorted by Stipend.
- List all students sorted by AvgMark in descending order.
- Display a report listing Name, Stipend, Stream and amount of stipend received in a year assuming that the Stipend is paid every month.
Solution:
SELECT * FROM STUDENT1
WHERE Stream="Nonmedical";SELECT Name
FROM STUDENT1
WHERE Class LIKE "12%"
ORDER BY Stipend;SELECT * FROM STUDENT1
ORDER BY AvgMark DESC;SELECT Name, Stipend, Stream, Stipend*12 AS 'Stipend per Year'
FROM STUDENT1;