0% found this document useful (0 votes)
30 views

Interview Questions

This document contains 25 SQL interview questions and answers about topics such as joins, data types, keys, aggregate functions, and more. The questions cover basic to advanced SQL concepts and range from short single-sentence questions to longer explanations. Sample code is provided for some answers.

Uploaded by

Balaji Suravase
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 (0 votes)
30 views

Interview Questions

This document contains 25 SQL interview questions and answers about topics such as joins, data types, keys, aggregate functions, and more. The questions cover basic to advanced SQL concepts and range from short single-sentence questions to longer explanations. Sample code is provided for some answers.

Uploaded by

Balaji Suravase
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/ 16

Top 25 SQL

Must-do Interview

Questions & Answers

www.tutort.net
+91-8712338901
Question #1

What are joins in SQL?

JOINS in SQL are commands which are used to combine

rows from two or more tables, based on a related column

between those tables.

Question #2

What are the different types of joins?

There are four main types of JOINs in SQL: INNER JOIN,

OUTER JOIN, CROSS JOIN, and SELF JOIN.

Different types of joins


Question #3

What is the difference between LEFT JOIN &


RIGHT JOIN?
The main difference between these joins is the inclusion of
non-matched rows. The LEFT JOIN includes all records
from the left side and matched rows from the right table,
whereas the RIGHT JOIN returns all rows from the right
side and unmatched rows from the left table.

Question #4

What is the difference between CHAR and


VARCHAR2 datatype in SQL?
The difference between a CHAR and a VARCHAR is that a
CHAR(n) will ALWAYS be N bytes long, it will be blank

padded upon insert to ensure

this. A varchar2(n) on the other

hand will be 1 to N bytes long,

it will NOT be blank padded.


Question #5

What is a primary key?


A primary key is an entry in a database that is unique to a
single record. This key is generally derived in one of two
ways: a unique identification code from outside the
database or a generated number from within the
database.

Question #6

What is a secondary key?


A secondary key is an additional key, or alternate key,
which can be used in addition to the primary key to locate
specific data.
Question #7

What is the difference between DELETE and

TRUNCATE statements?

The DELETE command in SQL

removes one or more rows from

a table based on the conditions

specified in those rows.

Question #8

What is a unique key?

A unique key is a set of one or more than one fields/

columns of a table that uniquely identify a record in a

database table.

Question #9

Write a SQL query to display the current date.

GETDATE() function returns the current database system

date and time


Question #10

What is a Foreign key in SQL?


A foreign key is a column (or combination of columns) in a
table whose values must match the values of a column in
some other table. FOREIGN KEY constraints enforce
referential integrity, which essentially says that if column
value A refers to column value B, then column value B must
exist.

Question #11

What is the difference between DROP and


TRUNCATE commands?
The DROP command is used to remove the whole
database or table indexes, data,

and more. Whereas the

TRUNCATE command is used to

remove all the rows from the table.


Question #12

Explain different types of indexes in SQL.


There are two types of Indexes in SQL Server
Clustered Inde
Non-Clustered Index

Clustered Index

A clustered index defines the order in which data is


physically stored in a table. Table data can be sorted in
only one way, therefore, there can be only one clustered
index per table. In SQL Server, the primary key constraint
automatically creates a clustered index on that particular
column.

Non-Clustered Indexes

A non-clustered index doesn’t sort the physical data inside


the table. In fact, a non-clustered index is stored in one
place and table data is stored in another place. This is
similar to a textbook where the book content is located in
one place and the index is located in another. This allows
for more than one non-clustered index per table.
Question #13

How many Aggregate functions are


available in SQL?
There are mainly five

aggregate functions,

which are: MIN, MAX,

COUNT, SUM, and AVG.

Question #14

What is the default ordering of data using


the ORDER BY clause? How could it be
changed?
In SQL ORDER BY clause, we need to define ascending or
descending order in which the result needs to be sorted.
By default, SQL Server sorts out results using the ORDER
BY clause in ascending order.
Question #15

How do we use the DISTINCT statement?


What is its use?

The SELECT DISTINCT statement is


used to return only distinct (unique)
values. Inside a table, a column often
contains many duplicate values; and
sometimes you only want to list the
unique (distinct) values.

Question #16

What are the syntax and use of the


COALESCE function?

The SQL server's Coalesce function is used to handle the


Null values.

The SQL COALESCE function can be syntactically


represented using the CASE expression. For example, as
we know, the Coalesce function returns the first non-NULL
values. SELECT COALESCE (expression1, expression2,
expression3) FROM TABLENAME;
Question #17

What are the set operators in SQL?


Set operators are used to combine or excluding the results
of two or more SELECT statement queries into a single
result set. They perform by combining rows from two or
more tables as opposed to columns in SQL joins. Set
operators are like mathematical operations.

Question #18

What is the difference between IN and


BETWEEN operators?
Both of these operators are used to find out the multiple
values from the table. The difference between these
operators is that the BETWEEN

operator is used to select a range

of data between two values while

The IN operator allows you to specify

multiple values.
Question #19

How to write an SQL query to find students'


names starting with 'A'?

SELECT * FROM Table WHERE STUDENT_NAME LIKE 'A%';

Question #20

Is a blank space or zero the same as a NULL


value?

Null indicates there is no value within a database field for


a given record. It does not

mean zero because zero is

a value. Blank indicates

there is a value within a

database but the field is

blank.
Question #21

What is meant by case manipulation


functions? Explains its different types in SQL.
Case-manipulation function is used to change the case of
character strings. The types of case-manipulation
functions are LOWER , UPPER , and INITCAP.

Question #22

Explain character-manipulation functions?


Explains its different types in SQL.
Character-manipulation functions are used to manipulate
character strings. The CONCAT, SUBSTR and REPLACE are
Character-manipulation

Character functions.
Question #23

Which function is used to return the


remainder in a division operator in SQL?
The MOD() function returns the remainder of a number
divided by another number.

Question #24

What is the difference between the WHERE


and HAVING clauses?
“Where” clause is used to filter the records from a table
that is based on a specified condition and the “Having”
clause is used to filter the record from the groups based
on the specified condition.

Question #25

Is it possible to implicitly insert a row for the


identity column?
You cannot INSERT values manually into an IDENTITY column.
Kick Start your

Data Science Career


Join Our
Full Stack Data Science

Master’s Course

Course Duration: 8 Months

Full Stack Artificial Intelligence

and ML course

Course Duration: 10 Months

Full Stack DS & AI Masters program


for Tech & Business Leaders

Course Duration: 10 Months

WhatsApp Now Talk with our experts Watch us on YouTube


Why Tutort Academy?
Profile Review by
Session with

Industry Experts 1:1 Mentorship

Real time projects from


100% guaranteed

Companies Job Calls

750+ Students placed at:

Explore more

www.tutort.net
Follow

for more such

informative content.

www.tutort.net +91-8712338901

You might also like