EmployeeInfo Table SQL Query
EmployeeInfo Table SQL Query
Q1. Write a query to fetch the EmpFname from the EmployeeInfo table in upper case and use the
ALIAS name as EmpName.
Q2. Write a query to fetch the number of employees working in the department ‘HR’.
SELECT GETDATE();
SELECT SYSTDATE();
Q4. Write a query to retrieve the first four characters of EmpLname from the EmployeeInfo table.
Q5. Write q query to find all the employees whose salary is between 50000 to 100000.
Q6. Write a query to find the names of employees that begin with ‘S’
Q8. Write a query to retrieve the EmpFname and EmpLname in a single column as “FullName”. The
first name and the last name must be separated with space.
Q9. Write a query find number of employees whose DOB is between 02/05/1970 to 31/12/1975 and
are grouped according to gender
SELECT COUNT(*), Gender FROM EmployeeInfo WHERE DOB BETWEEN '02/05/1970 ' AND
'31/12/1975' GROUP BY Gender;
Q10. Write a query to fetch all the records from the EmployeeInfo table ordered by EmpLname in
descending order and Department in the ascending order.
To order the records in ascending and descnding order, you have to use the ORDER BY statement in
SQL.
Q11. Write a query to fetch details of employees whose EmpLname ends with an alphabet ‘A’ and
contains five alphabets.
To fetch details mathcing a certain value, you have to use the LIKE operator in SQL.
Q12. Write a query to fetch details of all employees excluding the employees with first names,
“Sanjay” and “Sonia” from the EmployeeInfo table.
Q13. Write a query to fetch details of employees with the address as “DELHI(DEL)”.
Q14. Write a query to fetch all employees who also hold the managerial position.
Q15. Write a query to fetch the department-wise count of employees sorted by department’s count
in ascending order.
Q17. Write a query to retrieve the list of employees working in the same department.
Q18. Write a query to find the third-highest salary from the EmpPosition table.
Q19. Write a query to display the first and the last record from the EmployeeInfo table.
To display the first record from the EmployeeInfo table, you can write a query as follows:
To display the last record from the EmployeeInfo table, you can write a query as follows:
Q20. Write a query to retrieve Departments who have less than 2 employees working in it.