Home » Technical Interview Questions » SQL Interview Questions » SQL Query Interview Questions

SQL Query Interview Questions


Reading Time - 2 mins

21. Select first 3 characters of FIRST_NAME from EMPLOYEE?

SELECT SUBSTR (FIRST_NAME, 0, 3) FROM EMPLOYEE;

22. Get position of ‘o’ in name ‘John’ from employee table?

SELECT INSTR (FIRST_NAME,'o') FROM EMPLOYEE WHERE FIRST_NAME='John';

23. Get FIRST_NAME from employee table after removing white spaces from right side?

SELECT RTRIM (FIRST_NAME) FROM EMPLOYEE;

24. Get FIRST_NAME from employee table after removing white spaces from left side?

SELECT LTRIM (FIRST_NAME) FROM EMPLOYEE;

25. Get length of FIRST_NAME from employee table?

SELECT LENGTH (FIRST_NAME) FROM EMPLOYEE;

26. Get First_Name from employee table after replacing ‘o’ with ‘$’?

SELECT FIRST_NAME, REPLACE (FIRST_NAME,'o','$') FROM EMPLOYEE;

27. Get First_Name and Last_Name as single column from employee table separated by a ‘_’?

SELECT FIRST_NAME|| '_' ||LAST_NAME FROM EMPLOYEE;

28. Get FIRST_NAME, Joining year, Joining Month and Joining Date from employee table?

SELECT FIRST_NAME, 
	TO_CHAR(JOINING_DATE,'YYYY') JOINYEAR ,
	 TO_CHAR(JOINING_DATE,'MON'),
	   TO_CHAR(JOINING_DATE,'DD')     FROM        EMPLOYEE;

29. Get all employee details from the employee table order by First_Name Ascending?

SELECT * FROM EMPLOYEE ORDER BY FIRST_NAME ASC

30. Get all employee details from the employee table order by First_Name descending?

SELECT * FROM EMPLOYEE ORDER BY FIRST_NAME DESC;

READ  Optimization in SQL
Array Interview Questions
Graph Interview Questions
LinkedList Interview Questions
String Interview Questions
Tree Interview Questions