SQL SERVER QUERY INTERVIEW QUESTIONS - ANSWERS WITH EXAMPLE FOR FRESHER : SET-1 SOLUTION
SQL SERVER/Oracle/MySQL INTERVIEW QUERY SET : 1 WITH ANSWERS/SOLUTION
This is for both fresher and experienced developers which would be helpful for Interview preparation.
First try to answer these queries and put comment. After that see the answers of each query in solution set.
Download as PDF
Tables:-
MS SQL/Oracle/MySQL INTERVIEW QUERY FOR FRESHER SET : 1 SOLUTION
1. Write a query to get all employee detail from "EmployeeDetail" table
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail
Oracle: SELECT * FROM EmployeeDetail
MySQL: SELECT * FROM EmployeeDetail
MS SQL Server: SELECT * FROM EmployeeDetail
Oracle: SELECT * FROM EmployeeDetail
MySQL: SELECT * FROM EmployeeDetail
2. Write a query to get only "FirstName" column from "EmployeeDetail" table
ANS:
MS SQL Server: SELECT FirstName FROM EmployeeDetail
Oracle: SELECT FirstName FROM EmployeeDetail
MySQL: SELECT FirstName FROM EmployeeDetail
3. Write a query to get FirstName in upper case as "First Name".
ANS:
MS SQL Server: SELECT UPPER(FirstName) AS [First Name] FROM EmployeeDetail
Oracle: SELECT UPPER(FirstName) AS [First Name] FROM EmployeeDetail
MySQL: SELECT UPPER(FirstName) AS [First Name] FROM EmployeeDetail
4. Write a query to get FirstName in lower case as "First Name".
ANS:
MS SQL Server: SELECT LOWER(FirstName) AS [First Name] FROM EmployeeDetail
Oracle: SELECT LOWER(FirstName) AS [First Name] FROM EmployeeDetail
MySQL: SELECT LOWER(FirstName) AS [First Name] FROM EmployeeDetail
5. Write a query for combine FirstName and LastName and display it as "Name" (also include white space between first name & last name)
ANS:
MS SQL Server: SELECT FirstName +' '+ LastName AS [Name] FROM EmployeeDetail
Oracle: SELECT FirstName ||' '|| LastName AS [Name] FROM EmployeeDetail
MySQL: SELECT CONCAT(FirstName ,' ', LastName) AS [Name] FROM EmployeeDetail
6. Select employee detail whose name is "Vikas"
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName = 'Vikas'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName = 'Vikas'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName = 'Vikas'
7. Get all employee detail from EmployeeDetail table whose "FirstName" start with latter 'a'.
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like 'a%'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like 'a%'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like 'a%'
8. Get all employee details from EmployeeDetail table whose "FirstName" contains 'k'
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like '%k%'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like '%k%'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like '%k%'
9. Get all employee details from EmployeeDetail table whose "FirstName" end with 'h'
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like '%h'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like '%h'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like '%h'
10. Get all employee detail from EmployeeDetail table whose "FirstName" start with any single character between 'a-p'
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like '[a-p]%'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like '[a-p]%'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like '[a-p]%'
CLICK HERE FOR NEST SET (MORE THAN 100 QUERIES)
very useful for me
ReplyDeleteVery useful for me
ReplyDeleteWill all above queries work for normal D.Bases too? I saw these are server query interviews.
ReplyDeletethank u
ReplyDeleteSuperb
ReplyDeleteGreat Article it will help for Freshers as well as experienced professionals
ReplyDeleteGreat Article it will help for Freshers as well as experienced professionals
ReplyDeleteThanks all of above commenters for your kind comments
ReplyDeleteThanks all of above commenters for your kind comments
ReplyDeleteThanks a lot Vikas for preparing this Q&A series, really very much helpful.
ReplyDeleteShouldn't you use lower(Firstname) like 'a%' in question 7?
ReplyDeleteNo, bcoz it does not matter as sql query is not case sensitive.
DeleteSQL is case sensitive
DeleteDear Vikas really its very useful details shared by this blog .May you send me pdf of "SQL INTERVIEW QUESTION ANSWER" at vipinkamboj13@gmail.com
ReplyDeleteThank You sir.. Very UseFul
ReplyDeletedear anyone can provide a pdf of that type query on deepak.technologist@gmail.com
ReplyDeletesanketbeloshe2@gmail.com please give me pdf sir 1 to 6 sql basic questions answers
ReplyDeletecool
ReplyDeleteThis is an useful resource. Thank You :)
ReplyDeleteSo amazing
ReplyDeletehow to get this database schema
ReplyDeleteReally very helpful for freshers
ReplyDeleteThanks
Good explaination for the fresher, Thanks!!
ReplyDeletehi,how to insert date and time
ReplyDeleteGreat work
ReplyDeleteThanks
ReplyDelete