Let us try to answer common interview questions using below two tables – Employee and Incentive
Table of Contents
SQL Basics
1. Get all employee details from the employee table?
SELECT * FROM EMPLOYEE;
2. Get First_Name, Last_Name from employee table?
SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEE ;
3. Get First_Name from employee table using alias name “Employee Name”?
SELECT FIRST_NAME “EMPLOYEE NAME” FROM EMPLOYEE;
4. Get First_Name from employee table in upper case?
SELECT UPPER (FIRST_NAME) FROM EMPLOYEE;
5. Get FIRST_NAME from employee table in lower case?
SELECT LOWER (FIRST_NAME) FROM EMPLOYEE;
6. Get unique DEPARTMENT from employee table?
SELECT DISTINCT DEPARTMENT FROM EMPLOYEE;
7. Select first 3 characters of FIRST_NAME from EMPLOYEE?
SELECT SUBSTR (FIRST_NAME, 0, 3) FROM EMPLOYEE;
8. Get position of ‘o’ in name ‘John’ from employee table?
SELECT INSTR (FIRST_NAME,'o') FROM EMPLOYEE WHERE FIRST_NAME='John';
9. Get FIRST_NAME from employee table after removing white spaces from right side?
SELECT RTRIM (FIRST_NAME) FROM EMPLOYEE;
10. Get FIRST_NAME from employee table after removing white spaces from left side?
SELECT LTRIM (FIRST_NAME) FROM EMPLOYEE;