CBSE Class 12 Computer Science
Question 24 of 78
Simple Queries in SQL — Question 17
Back to all questions 17
Question Write SQL commands for the following on the basis of given table Teacher :
Table : Teacher
| No | Name | Age | Department | Salary | Sex | Dateofjoin |
|---|---|---|---|---|---|---|
| 1 | Jugal | 34 | Computer | 12000 | M | 1997-01-10 |
| 2 | Sharmila | 31 | History | 20000 | F | 1998-03-24 |
| 3 | Sandeep | 32 | Maths | 30000 | M | 1996-12-12 |
| 4 | Sangeeta | 35 | History | 40000 | F | 1999-07-01 |
| 5 | Rakesh | 42 | Maths | 25000 | M | 1997-09-05 |
| 6 | Shyam | 50 | History | 30000 | M | 1998-06-27 |
| 7 | Shiv Om | 44 | Computer | 21000 | M | 1997-02-25 |
| 8 | Shalakha | 33 | Maths | 20000 | F | 1997-07-31 |
- To show all information about the teacher of history department.
- To list the names of female teachers who are in Hindi department.
- To list names of all teachers with their date of joining in ascending order.
1.
SELECT *
FROM Teacher
WHERE Department = 'History' ;+----+----------+-----+------------+--------+-----+------------+
| No | Name | Age | Department | Salary | Sex | Dateofjoin |
+----+----------+-----+------------+--------+-----+------------+
| 2 | Sharmila | 31 | History | 20000 | F | 1998-03-24 |
| 4 | Sangeeta | 35 | History | 40000 | F | 1999-07-01 |
| 6 | Shyam | 50 | History | 30000 | M | 1998-06-27 |
+----+----------+-----+------------+--------+-----+------------+
2.
SELECT Name
FROM Teacher
WHERE Sex = 'F' and Department = 'Hindi' ;There are no records in the Teacher table where the department is 'Hindi'. Hence, there will be no output.
3.
SELECT Name, Dateofjoin
FROM Teacher
ORDER BY Dateofjoin ;+----------+------------+
| Name | Dateofjoin |
+----------+------------+
| Sandeep | 1996-12-12 |
| Jugal | 1997-01-10 |
| Shiv Om | 1997-02-25 |
| Shalakha | 1997-07-31 |
| Rakesh | 1997-09-05 |
| Sharmila | 1998-03-24 |
| Shyam | 1998-06-27 |
| Sangeeta | 1999-07-01 |
+----------+------------+