SQL Query
Consider the following two tables for the questions below:
TEACHER Table:
TID (INT, PK) Name (VARCHAR) Dept (VARCHAR) DOJ (Date) Salary (INT)
Gender (CHAR)
101 Anjali History 2015-11-13 50000 F
102 Rohan Maths 2016-04-21 45000 M
103 Vedika History 2018-07-19 52000 F
104 Karan English 2019-01-05 48000 M
105 Priya Maths 2020-03-10 46000 F
STUDENT Table:
RollNo (INT, PK) SName (VARCHAR) Class (INT) Marks (INT)
1 Alice 12 90
2 Bob 11 85
3 Charlie 12 75
4 David 11 92
5 Emily 12 88
Q1. Write the SQL command to display the name and salary of the highest-paid male teacher.
Q2. Write the SQL command to display the department-wise average salary, but only for those
departments where the average salary is above 48000.
Q3. Write the SQL command to list the names of all teachers with their date of joining in
ascending order, but display the date in the format "DD-Month-YYYY" (e.g., "13-November-
2015").
Q4. Write the SQL command to display the names of students whose names start with 'A' or 'E'
and are in class 12.
Q5. Write SQL commands to add a new column Remarks (VARCHAR(50)) to the STUDENT table
and then update the column to 'Excellent' for students who have marks greater than 85.