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/....

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)

Related

SQL SERVER 2517439827896244412

Post a comment

  1. very useful for me

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

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

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

    ReplyDelete
  5. Thanks all of above commenters for your kind comments

    ReplyDelete
  6. Thanks all of above commenters for your kind comments

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

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

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

      Delete
    2. SQL is case sensitive

      Delete
  9. 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

    ReplyDelete
  10. Thank You sir.. Very UseFul

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

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

    ReplyDelete
  13. This is an useful resource. Thank You :)

    ReplyDelete
  14. how to get this database schema

    ReplyDelete
  15. Really very helpful for freshers
    Thanks

    ReplyDelete
  16. Good explaination for the fresher, Thanks!!

    ReplyDelete
  17. hi,how to insert date and time

    ReplyDelete

emo-but-icon

Follow Us

Recent

Comments

Donate

Side Ads

Text Widget

Connect Us

Sql Server 2017 Interview Questions
Sql Server Basic Interview Query Set-1
Sql Server Basic Interview Query Set-2
Sql Server Date-Time Interview Query SET-3
Sql Server Salary Interview Query SET-4
Sql Server Group By Interview Query SET-5
Sql Server Join Interview Query SET-6
Sql Server Tricky Join Interview Query SET-7
Sql Server DDL Interview Query SET-8
Small but very Tricky Sql Server Query SET-9
Very Much Tricky Query (not 4 fresher)SET-10
Sql Server Complex Interview Query SET-11
Sql Server Datatype Interview Questions
Sql Server View Interview Questions
Sql Server Index Interview Questions
TCS Tricky Sql Interview Queries
HCL Sql Interview Queries
Sql Server SP Interview Questions
Sql Server Trigger Interview Questions
Sql Server Temp Table Interview Questions
Sql Server 2016 Interview Questions
Sql Server Performance Tuning Interview Q.
Sql Server Constraints Interview Questions
Sql Server Storage/Size Interview Questions
Sql Server Very Basic Interview Questions
Sql Server Quiz for Fresher
Sql Server Icon Quiz for All
Sql Server 300+ Theoretical Interview Questions
Sql Server Complete Set

ASP.NET AND JQUERY INTERVIEW QUESTION
ASP.NET: Web Config Interview Question
ASP.NET: View State Interview Question
ASP.NET: Session Interview Question
ASP.NET: Session Interview Question 
ASP.NET: Security Interview Question
ASP.NET: Catching Interview Question
C# OOPS Interview Question
MORE Interview Question
JQUERY: Interview Question Set-1
JQUERY: Interview Question Set-2
JAVA-SCRIPT: Interview Question Set-1
JAVA-SCRIPT: Interview Question Set-2
ASP.NET MVC: Interview Question Set-1

POPULAR POSTS
10 MOST DIFFICULT INTERVIEW QUESTIONS
5 BEST INTERVIEW TIPS
YOUR 10 MISTAKE DURING INTERVIEW
2016 TOP 20 GROUP DISCUSSION TOPICS
HOW SQL PERFORMANCE AFFECTED BY DATATYPE
item