Top 100 SQL Interview Questions and Answers

Are you planning to attend an SQL interview, is there an SQL interview scheduled for you? Then you are on the right page. We have researched a lot on SQL and prepared the most frequently asked SQL Interview Questions. Make sure you go through our entire post so that you will not miss any of the questions.

What is SQL? SQL, i.e., Structured Query Language, is designed to manage data in an RDBMS(Relational Database Management System). SQL is used for storing, manipulating, and retrieving the data stored in a relational database. RDBMS like MYSQL, Oracle, MS Access, Informix use SQL as their standard database language.

Contents show

Top 100 SQL Interview Questions and Answers

1. Can you tell us what a database is?

A database can be defined as a collection of information or data which is organized so that the user can easily access, manage, and update the data.

Example: Bank Management database, School Management database.

2. What is DBMS?

DBMS, i.e., Database Management System, can be defined as software designed for storing and accessing user’s data while taking the necessary security measures.

Examples: MYSQL, Microsoft Access, PostgreSQL, SQL Server, RDBMS, Clipper, and FoxPro.

3. What is SQL?

SQL can be defined as a Structured Query Language, which is used to communicate with the database. It is considered as the standard language used to perform tasks like accessing the database, updating, deleting, or inserting in the database. 

4. Can you explain what RDBMS is?

RDBMS, i.e., Relational Database Management System is used to store the data in a structured format called tables in the form of rows and columns.

5. Explain foreign key?

A foreign key is used to link two database tables. A foreign key can also be defined as a column or combination of columns whose value matches with the primary key in a different table.

6. What are the primary keys? Explain?

A primary key is a key in a relational database, which is unique for each record of the table. In simple words, it is a unique identifier. A table can be specified with only one primary key.

Example: Driver license number,  Vehicle Identification Number.

7.  What is an Index in SQL?

An Index in SQL consists of keys that are built from one or more columns in a table or view. These keys are stored in a structure in such a way that it enables the SQL server to find the row or rows that are associated with the specific key values quickly and efficiently.

8. What is a Unique key in SQL?

A Unique key in SQL is defined as a set of one or more fields or columns of a table that is used to uniquely identify a record from the database.

9. Explain Denormalization in SQL?

Denormalization can be defined as a strategy used on a previously normalized database to increase performance. In simple words, one can say it is a process of improving the read performance of a database. Here we add redundant data to one or more tables.

10. Explain Joins in SQL?

An SQL join can be defined as a join clause that is used for combining rows from two or more tables(multiple tables) based on the related columns between them.

SQL Interview Questions and Answers
“File:SQL Joins.svg” by Arbeck is licensed under CC BY 3.0

11. Explain different types of Normalization in SQL?

Database normalization can be defined as a process that needs to be carried out for each and every database you design. The mechanism of applying a set of formal criteria and rules is called Normal Forms.

The following are the types of Normalizations in SQL:

  1. First Normal Form (1 NF)
  2. Second Normal Form (2 NF)
  3. Third Normal Form (3 NF)
  4. Boyce Codd Normal Form or Fourth Normal Form ( BCNF or 4 NF)
  5. Fifth Normal Form (5 NF)
  6. Sixth Normal Form (6 NF)

12. Name the different types of DBMS?

We have four types of DBMS, namely,

  1. Network database
  2. Hierarchical database
  3. Relational database
  4. Object-oriented database

13. What are Entities and Relationships in SQL?

An entity in SQL is defined as a real object that exists. In a database, an entity can be defined as a person, place, or object.

A Relationship in SQL is formed correlating the rows that belong to different tables. A relationship can be created in a table when a child table specifies a foreign-key column that references the parent table’s primary key column.

We have three types of relationships in a database, namely,

  1. One-to-one
  2. One-to-many
  3. Many-to many

14.  What are Constraints in SQL?

SQL constraints are defined to specify rules for the data in the given table. They are mainly used to limit the type of data that goes into a table. Constraints can be either table level or column level where table-level constraints apply to the entire table, and the column level constraints apply to the specific columns.

15. Name the types of constraints in SQL?

The types of constraints in SQL are listed below:

  1. Not Null Constraint.
  2. Check Constraint
  3. Default Constraint
  4. Unique Constraint
  5. Primary Constraint
  6. Foreign Constraint

16. Can you explain the different types of Indexes in SQL?

In SQL, we have two main types of Indexes, namely,

  1. Clustered Index:  It changes the way that the rows are physically stored. When a clustered index is created for a column, the SQL server sorts the table’s rows based on the column.
  2. Non-Clustered Index: Here, the order of the rows does not match with the physical order of the actual data.

The other Indexes of SQL are:

  1. Unique Index
  2. Filtered Index
  3. Hash Index
  4. Columnstore Index

17. Differentiate between Delete and Truncate statements?

It deletes specific data.It deleted the whole data of the table.
It can rollback the changes.It cannot rollback the changes.
It is slower compared to truncate.It is faster.
WHERE clause can be used with deleteWe cannot use the WHERE clause with truncate.
It locks the specific table row before deleting the row.It locks the entire table upon deletion.

18. Can you explain the difference between CHAR and VARCHAR2 datatype in SQL?

It stores a character string of fixed length.It stores the character string of variable length.
CHAR means Character.VARCHAR2 means Variable character.
The performance is better than VARCHAR2.The performance is low.
It takes 1 byte for each character.It also takes 1 byte for each character, but it takes an extra space for holding the length information.
It is padded with extra memory space.It is not padded with extra memory space.

19. Name the different subsets of SQL?

The different subsets of SQL are:

  1. Data Definition Language(DDL):  This allows the user to perform different operations on the database such as DELETE, CREATE, and ALTER objects.
  2. Data Manipulation Language(DML): This also allows the user to access and manipulate the data. This helps us to insert, update, delete and retrieve data from the database.
  3. Data Control Language: This allows the user to control access to the database. Examples are Revoke and Grant access permissions.

20. What is a subquery?

A subquery, also defined as a Nested query or inner query, is a query that is placed within another SQL query and is embedded within the WHERE clause.

21. Name the different types of subquery?

The different types of subquery are listed below:

  1. Single-row subquery: This query returns a single row output.


SELECT department_id, MIN (salary)
FROM employees
GROUP BY department_id
HAVING MIN (salary)  < (SELECT AVG (salary)
FROM employees)
  1. Multiple row subquery: This query returns multiple row outputs.


SELECT first_name, department_id
FROM employees
WHERE department_id IN (SELECT department_id
                        FROM departments
                        WHERE LOCATION_ID = 100)
  1. Correlated subquery: It depends on the data provided by the outer query.


SELECT EMPLOYEE_ID, salary, department_id
FROM   employees E
WHERE salary > (SELECT AVG(salary)
                FROM   EMP T
                WHERE E.department_id = T.department_id)

22. Explain the types of different joins available in SQL?

The different types of SQL joins are mentioned below:

Inner Join: This join returns rows when there is a match(at least one) of rows between the tables.

Right Join: This join returns the rows that are common between the tables and the rows that are on the right-hand side of the table.

Left Join: This join returns the rows that are common between the tables and the rows that are on the left-hand side of the table.

Full Join: This join returns the rows when it finds a matching row in any one of the tables. Here, it returns all the rows from both the left-hand side and right-hand side of the table.

23. What is a view in SQL?

A view in SQL is defined as a virtual table that contains a subset of data that is contained in a table. Views are not actually present, and they take less memory space. A view can have data from multiple tables depending on the relationship.

24. What is an ALIAS command in SQL?

Aliases in SQL are used to give a temporary name to a table or a column in a table. They are used to make column names more readable. Alias exists only for that particular period of that query.

25. What is CLAUSE in SQL? Explain?

The WHERE clause in SQL is used to define a specific condition while retrieving the data from a single table or multiple tables that are joined using the join. The WHERE clause returns values from the specific table only if it satisfies the given condition. It is mostly used to filter records and to fetch only the required records from the table.

26. What is the need for a MERGE statement in SQL?

A MERGE statement in SQL can be defined as the combination of three statements, namely, INSERT, UPDATE, and DELETE.  If you want to merge a source table with a target table, you can make use of all the three MERGE statements( INSERT, UPDATE, DELETE) at once.

 Example :

MERGE <target_table> [AS TARGET]th
USING <table_source> [AS SOURCE]
ON <search_condition>
   THEN <merge_matched> ]
   THEN <merge_not_matched> ]
   THEN <merge_matched> ];

27. Can you explain the need for group functions in SQL?

The GROUP BY statements in SQL are used to group rows that have the same values into summary rows. These statements are usually used with aggregate functions like COUNT(), MAX(), MIN(), SUM(), and AVG() in order to group the result-set by one or more columns.

The syntax for GROUP BY statements:

SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);

28. What are aggregate and scalar functions in SQL?

Aggregate functions in SQL are used to operate against a set of values and return a single summarizing value.

Examples: AVG(), COUNT(), FIRST(), LAST(), MIN(), MAX(), SUM().


The scalar function in SQL returns a single value based on the given scalar input arguments. Few scalar functions like CURRENT-TIME may not require any arguments.

Example: UCASE(), LCASE(), MID(), LEN(), ROUND(), NOW(), FORMAT().


29. What is the difference between ‘BETWEEN’ and ‘IN’ condition operators?

Between operators in SQL is used to select a range of data between the two values. The values here can be any numbers, text, etc.


SELECT * FROM table_name
WHERE column_name BETWEEN 'value1' AND 'value2'

The IN Operator in SQL is used to specify multiple values.


SELECT * FROM table_name
WHERE column_name IN ('value1','value 2')

SQL Interview Questions and Answers

30. Differentiate between HAVING Clause and WHERE Clause?

It is used for the selection of rows according to the specified condition.It is used in column operations and is applied to aggregated groups or rows.
Having clause cannot be used with SELECT statementsWHERE clause is used with SELECT, UPDATE, DELETE, etc.
HAVING clause can include the aggregate functions like min, max, etc.It cannot make use of the aggregate functions.
Example: SELECT * FROM Table HAVING age = 10Example: SELECT * FROM Table WHERE age = 10

Top SQL Interview Questions and Answers

31. Can you list some case manipulation functions in SQL?

CONTACT(): It is used to integrate multiple strings into a single string.

Syntax: CONCAT(first_name, second_name,……n_name)

SUBSTR(): It is defined as a substring, or it takes apart from the string and returns it.

Syntax: SUBSTR(char, position, length)

TRIM():  It is used to delete all the related characters from the initial part, which is called leading, and it deletes the characters from the last part called trailing, or it removes both the parts known as edit-char.

Syntax: TRIM([[LEADING|TRAILING|BOTH] character FROM] edit_char)

CHR and ASCII: The ASCII function is used to return the ASCII value of the characters’ expression leftmost character.

Syntax: ASCII(Single_character)

The CHR function accepts the ASCII code and returns the related character.

 Syntax: CHR(Character_code)

REPLACE(): This is used to remove or replace data selectively from an SQL string.

Syntax: REPLACE(entry_name, string_searching, string_replace)

There are many other manipulation functions, namely, Instr, length, Rtrim, Rpad, Lpad, InitCap, Lower, Upper.

32. Explain how to insert NULL values in a column while inserting the data?

We can insert NULL values in SQL in the following ways:

  1. You can implicitly insert by omitting the columns from the column list.
  2. You can do this explicitly by defining the NULL keyword in the VALUES clause.

33. Can you list the ways to get the count of records in a table?

We use the below-mentioned commands to count the number of records in a table.

SELECT * FROM Sampletable1
SELECT COUNT(*) FROM Sampletable1
SELECT rows FROM sysindexes WHERE id = OBJECT_ID(Sampletable1) AND indid < 2

34. Can you list the ways in which Dynamic SQL can be executed?

The following mentioned are the ways in which you can execute the dynamic SQL:

  1. By writing a query with parameters
  2. By using EXEC
  3. Using sp-executesql

35. Can you write a SQL query to find the names of employees that begin with ‘A’?

SELECT * FROM Table_name WHERE EmpName like 'A%';

36. Can you name the operator which is used in the query for pattern matching?

For pattern matching in SQL, we use the LIKE operator.

  1. %: In SQL, it is used to match zero or more characters.
Example: select * from students where studentname like ‘a%.’
  1. The Underscore(_): It is used to match exactly one character.
Select * from student where studentname like ‘xyz’.

37. What are Local and Global variables in SQL?

The local variables are the variables that are defined within the function, and they are not referred to by any other functions.

The Global Variables are the variables that can be accessed throughout the program, and they can be referenced by other functions.

38. Name the different authentication modes in SQL Server? 

The different authentication modes in the SQL server are:

  1. Windows mode
  2. Mixed mode

39. Name the different types of Collation Sensitivity?

The different types of collation sensitivity are:

  1. Case Sensitivity
  2. Kana Sensitivity
  3. Width Sensitivity
  4. Accent Sensitivity

40. What is a Collation?

A Collation can be defined as a set of rules that determines how to sort data and compare data. For example, Character data can be sorted using the rules that specify the correct character sequence along with specifying character width, case-sensitivity, etc.

Top SQL Interview Questions and Answers

41. What are the recursive stored procedures?

Recursive stored procedures in SQL are referred to a stored procedure that calls by itself until it reaches the specified boundary conditions. This process helps the programmers to reuse the code any number of times.

42. Can you list all the types of user-defined functions?

We have three types of user-defined functions, namely,

  1. Scalar Functions.
  2. Inline Table-valued Functions.
  3. Multi Statement-valued functions.

43. Explain Auto-Increment in SQL?

Auto-Increment is defined as a keyword that allows us to create a unique number that is automatically generated whenever a new record is created in the table. This keyword is used with the PRIMARY KEY.

AUTOINCREMENT keyword is used in Oracle.

IDENTITY keyword is used in SQL Server.

44. Explain STUFF and REPLACE function?

 STUFF Function: It is used to overwrite the existing character, or it can be used to insert a string into another or different string.

Syntax: STUFF(string_expression,start, length, replacement_characters)

REPLACE Function: As the name suggests, it is used to replace the existing characters.

Syntax: REPLACE (string_expression, search_string, replacement_string)

45. Differentiate between SQL Vs. NoSQL?

It is a relational database.It is not a relational database.
It is a structured query language and has a predefined schema.They have dynamic schemas for unstructured data.
They are table-based.They are document, key-value, graph-based.

46. Can you compare SQL with Oracle? 

SQL ServerOracle
It is developed by Microsoft.It is owned by Oracle.
It uses T-SQL.It uses  PL/SQL.
There is no concept of packages in SQL ServerIt supports packages.
Here, the users cannot share the database.It allows the users to share the databases.

47. Explain Datawarehouse?

Datawarehouse can be referred to as a central repository of data where the data is assembled from various sources. The assembled data can be transformed, and it can be made available for mining and online processing.

48. Differentiate between SQL and MySQL?

It is a query language.It is a relational database that uses SQL to query.
It is used to access, update and manipulate the data.It stores the existing data in an organized manner.
It is used to write queries for databases.It facilitates modifying data, storing data in a tabular format.

49. What is a trigger in SQL?

A trigger in SQL can be defined as a special type of stored procedure that can automatically run whenever an event occurs in the database server.

Top SQL Interview Questions and Answers

50. What is a Natural Join in SQL?

A Natural join in SQL compares all the columns of two specified tables that have the same column name, where the columns must be of the same data type.


FROM table1

51. What is T-SQL? 

T-SQL called Transact SQL is a group of programming extensions that are derived from Sybase.  It includes the several features added by Microsoft to the SQL, including error handling, transaction control, declaring variables, and row processing.

52. What is a Cross Join in SQL?

The Cross joins in SQL are used to generate a paired combination of the first table rows with the second table rows. It is also known as cartesian join. 

53. What is a forward cursor in SQL?

Forward cursor in SQL is defined as retrieving rows from start to end in a result set. This will not allow you to go to the previous row in the result set.

54. Define COMMIT in SQL?

COMMIT statement is used in SQL to end the current transactions and make permanent changes in the transaction. A transaction can be defined as a sequence of SQL statements.

55. What is a schema in SQL? 

A schema in SQL can be defined as a logical collection of database objects. Some of the SQL objects are Tables, Views, Functions, Stored procedures, Triggers, Indexes.

56. What is a transaction log in SQL?

A transaction log in SQL is used to record all the transactions and database modifications that are made by each transaction. It is a very important or critical component of the database. Whenever there is a system failure, you will need this transaction log to bring it back to a consistent state.

57. What are Object Privileges in SQL?

An Object-level privilege can be defined as the permission that is granted to a database user account or for a role to perform a specific action on a database object. The privileges include INSERT, SELECT, UPDATE,  INDEX, ALTER, on tables, and views.

58. What is lock escalation in SQL?

The lock escalation in SQL is the mechanism of converting many fined-grained locks into Table locks. Some of the application queries may trigger lock escalation when it is not desirable.

59. What is a SYSTEM Privilege in SQL?

A SYSTEM privilege can be defined as the right to perform a specific action or to perform an action on any object. The objects here include Tables, views, Indexes, cache groups, PL/SQL functions, procedures, replication schemas, materialized view, and packages.

60. What is a shared lock in SQL?

Shared locks in SQL are automatically acquired when the data is read. They can be held on a table, index key, page, and an individual row.

SQL Interview Questions and Answers

61. What is a NULL Value field in SQL?

A NULL value field in SQL can be defined as a table field that has no value. It is different from a zero value or a field that contains spaces.

62. Define SQL injection? 

SQL injection in SQL can be defined as a code injection technique that might destroy the database. We can say It is one of the most commonly used web hacking techniques.

63. What is a deadlock in SQL?

A deadlock in SQL occurs when the two processes are competing for the same resource, and one of the processes is unable to access it because the other process is preventing from accessing it. When an SQL server encounters a deadlock, it takes action by killing one of the processes.

64. What is a composite key in SQL?

A composite key can be defined as a primary key that has two or more attributes. It has to be a combination of two or more columns. 

65. What is data integrity in SQL?

Data Integrity in SQL maintains the accuracy and consistency of the data in the table.

66. What is a UNION operator in SQL?

Union operators in SQL are used to combine the result sets of two or more select statements. This operator removes the duplicate rows from the different select statements.


SELECT column_name(s) FROM table1
SELECT column_name(s) FROM table2;

67. Name the character manipulation functions?

Some of the character manipulation functions are ALTER, EXTRACT, CHANGE, and CHARACTER STRING.

68. Explain One-Many Relationship in SQL?

In a One-to-many relationship, one record in a table can be related to one or more records in another table.

69. What are case manipulation functions in SQL?

The Case manipulation functions in SQL are used to convert the existing data in the table to lower case, upper case, or mixed case characters.

70. Differentiate between the table and filed in SQL?

A table in SQL is a data structure where data is organized in fields and records.

The table in the database contains rows and columns. Here the rows are called records, and the columns are called fields.

71. Explain the role of GRANT and REVOKE commands?

The GRANT command in SQL is a DCL command used to confer authority to the users.  


GRANT privilege_name
ON object_name
TO {user_name |PUBLIC |role_name}

REVOKE command in SQL is used to withdraw the authorization from the users.


REVOKE privilege_name
ON object_name
FROM {user_name |PUBLIC |role_name}

72. What does the VAR function do in SQL? 

The VAR function of SQL returns the variance of the total number of records that are present in the specified column.


SELECT VAR ([YearlyIncome]) AS [Variance Income]    
  FROM [Customer]

73. Can you write the SQL query to get the current date?


74. Name the different case manipulation functions in SQL?

The different case manipulation functions in SQL are:

  1. Lower: It converts all the characters into lowercase.
  2. Upper: It is used to convert all the characters into uppercase.
  3. Init Cap: It converts all the initial characters of each word to uppercase.

75. Explain inconsistent dependency?

Inconsistent dependency can be defined as the difficulty of accessing the data because of the path that is broken or missing. It allows the user to search the data in the wrong tables, which later displays an error in the output. 

76. Explain the difference between null, zero, and blank space?

NULL in SQL refers to a value that is not available, or unknown, or unassigned.

Zero in SQL is defined as a number.

Blank space in SQL is treated as a character.

77. What is a set-based solution? Explain?

The Set-based solution makes use of T-SQL queries to operate on the input tables as sets of rows. In simple terms, SQL Server performs on a complete set of rows and returns the manipulated subset of rows.

78. How can you sort records in a table SQL?

The ORDER-BY keyword is used to sort records in the table either in ascending or descending order. To sort the records in descending order, one has to make use of the keyword DESC.


SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;

79. Explain the UNIQUE constraint?

A UNIQUE constraint in SQL ensures that all the values in a column are unique and different. This helps to identify each record uniquely. A table can have multiple key constraints.


LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int

80. What is a self join in SQL?

A self-join can be defined as a regular join, where a table is joined to itself based on the relationship between its own columns.


SELECT column_name(s)
FROM table1 T1, table1 T2
WHERE condition;

81. What is a query in the database?

A query in SQL is defined as a request for information. The database query can be a select query or an action query.

We use Select queries in SQL to select data from the database using the SELECT statements. The data that is returned here is stored in a result table known; as a result, set.


SELECT * FROM table_name;

An action query in SQL is a query that makes changes to records, or it may move multiple records in one operation.

82. Name some common clauses used with SELECT query in SQL?

Some of the common clauses used with SQL statements are listed below.

WHERE Clause: Mainly used to filter records based on the given condition.


Select * from employees
WHERE location = ‘ XYZ.’

ORDER BY: It is used by SQL to sort the records based on the fields in ascending or descending order.


Select * from customers
ORDER BY country DESC;

GROUP BY: It is used to group the records with identical data and can be used with aggregate functions.


SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country;

Having: It is used to filter records in combination with the GROUP BY clause.


SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
HAVING COUNT(CustomerID) > 5;

83. Explain the DROP statement in SQL?

Drop command in SQL is used to remove an object from a database.


Drop table Employees;

84. Can you create empty tables with the same structure as another table?

SQL allows us to create an empty table with the same structure by fetching the records of one table and by using the INTO operator using the WHERE clause. The SQL here creates a new table with a duplicate structure that can accept the fetched records since we are using the WHERE clause, no records are fetched, and nothing is inserted into the new table.


SELECT * INTO Students_copy
FROM Students WHERE 1 = 2;

85. Mention a few usages of SQL?

  1. SQL is used for maintaining the relational data and the data structures present in the database.
  2. It is used to execute queries against a database.
  3. To retrieve or access data from a database.
  4. SQL inserts the records in a database.
  5. To update the records in a database.
  6. To delete records from a database.
  7. To create new databases.
  8. SQL is used to create new tables in a SQL database.
  9. It creates views in a database.
  10. It is used to perform complex operations on the database.

86. Does SQL support programming? Explain?

SQL is not really a programming language. It does not support loops, conditional statements, and logical operations. You cannot use SQL for any other things except for data manipulation. The main intention of SQL is to retrieve, update, and manipulate data.

87. Explain Data Manipulation Language?

Data Manipulation Language is used to enable data manipulations. It performs the following operations.

  1. It Inserts the data into the database through the INSERT command.
  2. It Retrieves the data from the database through the SELECT command.
  3. You can update the data in the database through the UPDATE command.
  4. It Deletes the data from the database through the DELETE command.

88. Explain Data Control Language?

The Data Control Language allows the user to control access to the database. It is the only subset of the database that decides which part of the database should be accessed by which user at a certain point in time.

89. Differentiate between Primary key and Unique key?

Primary keyUnique key
A table can be specified with only one primary key.A table can have more than one unique key.
It creates clustered index.It creates a non-clustered index.
It serves as a unique identifier.It identifies a row that is not a primary key.

90. What is a Unique Index in SQL?

A Unique Index in SQL guarantees that the index key does not contain any duplicate values so that every row in the table is unique.

91. Can you sort a column using a column alias?

To sort a column using column alias, you have to use the column alias ORDER BY instead of the WHERE clause.

92. What are set-operators?

SQL queries that contain set operators are known as compound queries.

The set operators used in SQL are Union, Union All, Intersect, or minus operators.

93. Tell me about the various level of constraints?

There are two levels of constraints:

  1. Column level constraint
  2. Table level constraints

94. Explain ACID property?

The ACID property ensures reliable data transactions.ACID stands for Atomicity, Consistency, Isolation, Durability.

95. Why do we use the NVL() function?

The NVL() function in SQL is used to convert NULL values to other values.

NVL() function is used in oracle.

MySQL supports IFNULL()

SQL Server has ISNULL() function.

96. Tell us how to fetch common records from two tables?

Using the INTERSECT, we can fetch common records from two tables.

Example: Select studentID from student. <strong>INTERSECT </strong> Select StudentID from Exam

97. Write the syntax and use of the COALESCE function?

The syntax for COALESCE function is mentioned below:

COALESCE(exp1, exp2, .... expn)  

The function returns the first non-null expressions that are given in the parameter list.

98. What is a Distinct keyword?

DISTINCT keyword ensures that the fetched value is a non-duplicate value.

99. Can you write an SQL query to get the third maximum salary of an employee from a table named employee_table?

SELECT TOP 1 salary   
FROM (  
SELECT TOP 3 salary  
FROM employee_table  
ORDER BY salary DESC ) AS emp  
ORDER BY salary ASC;      

100. Can you tell us why * is used in SQL?

In SQL * means all records.

Example: Select * from employee table;

Here the SQL selects all the records from the employee table.

Good Luck with your SQL Interview, and we hope our SQL Interview Questions and Answers were of some help to you. You can also check our PL/SQL Procedure Interview Questions and Network Security Interview Questions.