SQL SERVER QUERY INTERVIEW QUESTIONS - ANSWERS WITH EXAMPLE FOR FRESHER : SET-1 SOLUTION

SQL SERVER/Oracle/MySQL INTERVIEW QUERY SET : 1 WITH ANSWERS/SOLUTION

Here I come with more than 100 SQL Server queries for Database/.NET/SQL Server developers, Soon you will get more than 100 SQL query set in pdf/ebook format. So keep visiting this page.
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


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 on the following link for NEXT SET OF QUESTIONS:
CLICK HERE FOR NEST SET (MORE THAN 100 QUERIES)

Comments

  1. very useful for me

  2. Very useful for me

  3. Will all above queries work for normal D.Bases too? I saw these are server query interviews.

  4. thank u

  5. Superb

  6. Great Article it will help for Freshers as well as experienced professionals

  7. Great Article it will help for Freshers as well as experienced professionals

  8. Thanks all of above commenters for your kind comments

  9. Thanks all of above commenters for your kind comments

  10. Thanks a lot Vikas for preparing this Q&A series, really very much helpful.

  11. Shouldn't you use lower(Firstname) like 'a%' in question 7?

    Replies
    1. No, bcoz it does not matter as sql query is not case sensitive.

    2. SQL is case sensitive

  12. Dear Vikas really its very useful details shared by this blog .May you send me pdf of "SQL INTERVIEW QUESTION ANSWER" at vipinkamboj13@gmail.com

  13. Thank You sir.. Very UseFul

  14. dear anyone can provide a pdf of that type query on deepak.technologist@gmail.com

  15. sanketbeloshe2@gmail.com please give me pdf sir 1 to 6 sql basic questions answers

  16. cool

  17. This is an useful resource. Thank You :)

  18. So amazing

  19. how to get this database schema

  20. Really very helpful for freshers
    Thanks

  21. Good explaination for the fresher, Thanks!!

  22. hi,how to insert date and time

  23. Great work

  24. Thanks

Emotions
Copy and paste emojis inside comment box

Contact Form

Send