0% found this document useful (1 vote)
2K views14 pages

A4academics Com Interview Questions 53 Database and SQL 397

hello read this

Uploaded by

Abhishek Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views14 pages

A4academics Com Interview Questions 53 Database and SQL 397

hello read this

Uploaded by

Abhishek Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Our Services | Write for Us | Study in US | Post a Question

Search our Blog


Home

Career Tips

Interview Questions

Jobs

Placement Test

Seminar Topics

B.E Projects

Soft Skills

Tutorials
AdChoices

SQL Queries

Database SQL

SQL Server 2008

SQL Tutorial

Top 80 + SQL Query Interview Questions and Answers with


Examples
601 Votes

Last Updated: 30 July 2016

Hits: 429547

Frequently asked basic and advanced Top 80 + SQL Queries Interview Questions and Answers with
Examples for Business Analyst, Data Analyst, DBA, Freshers and Experienced Java, PHP, Dot Net
programmers in Oracle, MySQL and MS SQL Database.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Are you an Experienced Programmer or Database Administrator ? If so, visit our Interview
Questions on Advanced and Complex SQL Query section of this article. For each question, if the SQL
Commands differ for Oracle, MySQL and SQL Server Databases, specific queries with respect to a
database is provided. If the answers are same for all databases, only one query is specified. Interview
Questions on SQL are based on following two tables, Employee Table and Employee Incentive Table.

Table Name : Employee

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Employee_id First_name Last_name Salary

Joining_date

Department

John

Abraham

1000000 01-JAN-13 12.00.00 AM Banking

Michael

Clarke

800000

01-JAN-13 12.00.00 AM Insurance

Roy

Thomas

700000

01-FEB-13 12.00.00 AM Banking

Tom

Jose

600000

01-FEB-13 12.00.00 AM Insurance

Jerry

Pinto

650000

01-FEB-13 12.00.00 AM Insurance

Philip

Mathew

750000

01-JAN-13 12.00.00 AM Services

TestName1

123

650000

01-JAN-13 12.00.00 AM Services

TestName2

Lname%

600000

01-FEB-13 12.00.00 AM Insurance

Table Name : Incentives


Employee_ref_id Incentive_date Incentive_amount

open in browser PRO version

01-FEB-13

5000

01-FEB-13

3000

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

01-FEB-13

4000

01-JAN-13

4500

01-JAN-13

3500

SQL Queries Interview Questions and Answers on "SQL Select"


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

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

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

Don't Miss - SQL and Database theory Interview Questions


open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

7. Select first 3 characters of FIRST_NAME from EMPLOYEE


Oracle Equivalent of SQL Server SUBSTRING is SUBSTR, Query : select
substr(FIRST_NAME,0,3) from employee

SQL Server Equivalent of Oracle SUBSTR is SUBSTRING, Query : select


substring(FIRST_NAME,1,3) from employee

MySQL Server Equivalent of Oracle SUBSTR is SUBSTRING. In MySQL start position is 1,


Query : select substring(FIRST_NAME,1,3) from employee

8. Get position of 'o' in name 'John' from employee table


Oracle Equivalent of SQL Server CHARINDEX is INSTR, Query : Select instr(FIRST_NAME,'o')
from employee where first_name='John'

SQL Server Equivalent of Oracle INSTR is CHARINDEX, Query: Select


open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

CHARINDEX('o',FIRST_NAME,0) from employee where first_name='John'

MySQL Server Equivalent of Oracle INSTR is LOCATE, Query: Select


LOCATE('o',FIRST_NAME) 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

11. Get length of FIRST_NAME from employee table


Oracle,MYSQL Equivalent of SQL Server Len is Length , Query :select length(FIRST_NAME)
from employee

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

SQL Server Equivalent of Oracle,MYSQL Length is Len, Query :select len(FIRST_NAME) from
employee

12. Get First_Name from employee table after replacing 'o' with '$'
select REPLACE(FIRST_NAME,'o','$') from employee

13. Get First_Name and Last_Name as single column from employee table separated by a '_'
Oracle Equivalent of MySQL concat is '||', Query : Select FIRST_NAME|| '_' ||LAST_NAME from
EMPLOYEE

SQL Server Equivalent of MySQL concat is '+', Query : Select FIRST_NAME + '_' +LAST_NAME
from EMPLOYEE

MySQL Equivalent of Oracle '||' is concat, Query : Select concat(FIRST_NAME,'_',LAST_NAME)


from EMPLOYEE
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

14. Get FIRST_NAME ,Joining year,Joining Month and Joining Date from employee table
SQL Queries in Oracle, Select FIRST_NAME, to_char(joining_date,'YYYY') JoinYear ,
to_char(joining_date,'Mon'), to_char(joining_date,'dd') from EMPLOYEE

SQL Queries in SQL Server, select SUBSTRING (convert(varchar,joining_date,103),7,4) ,


SUBSTRING (convert(varchar,joining_date,100),1,3) , SUBSTRING
(convert(varchar,joining_date,100),5,2) from EMPLOYEE

SQL Queries in MySQL, select year(joining_date),month(joining_date), DAY(joining_date) from


EMPLOYEE

Page 1 of 7
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Pages

You are here: Home > Interview Questions > Database & SQL Interview Questions and Answers > Top 80 + SQL Query Interview
Questions and Answers with Examples

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Popular Posts
HR Interview Questions and Answers
SQL Interview Questions and Answers
Java Interview Questions and Answers
SQL Query Interview Questions and Answers
Careers Choices and Job Opportunities for Electronics and Communication Engineers

Related Articles
Database/SQL Interview Questions and Answers for Freshers, Experienced
Oracle Interview Questions and Answers on SQL Queries and Database Theory
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Advanced SQL Interview Questions and Answers


SQL Server Interview Questions and Answers
Top 100 C# Interview Questions and Answers
.Net Framework Interview Questions and Answers
ADO.Net Interview Questions and Answers for Freshers, Experienced
ASP.Net Interview Questions and Answers
ASP.Net MVC Interview questions and Answers
WCF Interview Questions and Answers
ASP.Net Web API Interview Questions
Java OOPS Interview Questions and Answers
Top 150+ Java Interview Questions and Answers
Top Advanced Java Interview Questions and Answers

Popular Categories
Database Interview Questions and Answers
.Net Interview Questions and Answers
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Core Java & Swing Interview Questions


C Interview Questions and Answers
HR Interview Questions and Answers
Aptitude Test - Tips, Tricks and Shortcuts
Seminar Topics for CSE, MCA, I.T
Seminar Topics for ECE
MBA after Engineering - Courses & Top Colleges

Search our Site


Enter Search Term

Email Newsletter
Enter your Email Address and get interesting updates
Your email Address...

Subscribe
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Quick Links
Home

B.E Projects

Careers Jobs

Tutorials

Interview Questions

Blog

Placement Test

Forum

Seminar Topics

Contribute Projects & Seminars

Quick Contacts

Follow us on

E: [email protected]
W: www.a4academics.com

Copyright 2014 A4Academics. All rights reserved.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

Privacy & Terms

About Us Contact Us Advertise

pdfcrowd.com

You might also like