Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
253k views
in Computer by (46.2k points)
closed by

Write SQL commands for the following queries (i) to (v) based on the relations Teacher and Posting given below:

Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
1 Jugal 34 Computer Sc 10/01/2017 12000 M
2 Shaemila 31 History 24/03/2008 20000 F
3 Sandeep 32 Mathematics 12/12/2016 30000 M
4 Sangeeta 35 History 01/07/2015 40000 F
5 Rakesh 42 Mathematics 05/09/2007 25000 M
6 Shyam 50 History 27/06/2008 30000 M
7 Shiv Om 44 Computer Sc 25/02/2017 21000 M
8 Shalakha 33 Mathematics 31/07/2018 20000 F

Table : Posting
P_ID Department Place
1 Histoty Agra
2 Mathematics Raipur
3 Computer Science Delhi

i. To show all information about the teacher of History department. 

ii. To list the names of female teachers who are in Mathematics department. 

iii. To list the names of all teachers with their date of joining in ascending order. 

iv. To display teacher’s name, salary, age for male teachers only. 

v. To display name, bonus for each teacher where bonus is 10% of salary.

2 Answers

+1 vote
by (17.0k points)
selected by
 
Best answer

(i) To show all information about the teacher of the History department, the WHERE clause followed by the condition ie., DEPARTMENT=’History’ should be used in the query.

QUERY: SELECT * FROM TEACHER WHERE DEPARTMENT='History';

(ii) To list the names of female teachers who are in the Mathematics department, the WHERE clause followed by the condition ie., GENDER=’F’ AND DEPARTMENT=’Mathematics’ should be used in the query.

QUERY:  SELECT NAME FROM TEACHER WHERE GENDER='F' AND DEPARTMENT='Mathematics';

(iii) To list the names of all teachers with their date of joining in ascending order, the ORDER BY clause followed by the column name ie., DATE_OF_JOIN should be used in the query.

QUERY: SELECT NAME FROM TEACHER ORDER BY DATE_OF_JOIN;

(iv) To display teacher’s name, salary, age for male teachers only, the WHERE clause followed by the condition ie., GENDER=’M’ should be used in the query.  

QUERY: SELECT NAME,SALARY,AGE FROM TEACHER WHERE GENDER='M';

(v) To display name, bonus for each teacher where bonus is 10% of salary, the statement salary*0.1 AS BONUS should be used in the query.

QUERY: SELECT NAME,SALARY*0.1 AS BONUS FROM TEACHER;

+2 votes
by (49.2k points)

i. SELECT * FROM teacher WHERE department= “History”; 

ii. SELECT name FROM teacher WHERE department= “Mathematics” AND gender= “F”; 

iii. SELECT name FROM teacher ORDER BY date_of_join; 

iv. SELECT name, salary, age FROM teacher WHERE gender=’M’; 

v. SELECT name, salary*0.1 AS Bonus FROM teacher;

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...