Advertisements
Advertisements
प्रश्न
Given the following tables:
Table: STUDENTS
| S_ID | NAME | AGE | CITY |
| 1 | Rahul | 20 | Delhi |
| 2 | Priya | 22 | Mumbai |
| 3 | David | 21 | Delhi |
| 4 | Neha | 23 | Bengaluru |
| 5 | Khurshid | 22 | Delhi |
Table: GRADES
| S_ID | SUBJECT | GRADE |
| 1 | Math | A |
| 2 | English | B |
| 3 | Math | C |
| 4 | English | D |
| 5 | Math | E |
Write SQL queries for the following:
- To display the number of students from each city.
- To find the average age of all students.
- To list the names of students and their grades.
कोड लेखन
Advertisements
उत्तर
SELECT CITY, COUNT(*) FROM STUDENTS GROUP BY CITY;SELECT AVG(AGE) FROM STUDENTS;SELECT S.NAME, G.GRADE FROM STUDENTS S JOIN GRADES G ON S.S _ ID = G.S _ ID;
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Set 4
