Top sql interview questions for 3 years experience

Are you an aspiring SQL Developer? A career in SQL has seen an upward trend in 2023, and you can be a part of the ever-so-growing community. So, if you are ready to indulge yourself in the pool of knowledge and be prepared for the upcoming SQL interview, then you are at the right place.

Show

We have compiled a comprehensive list of SQL Interview Questions and Answers that will come in handy at the time of need. Once you are prepared with the questions we mentioned in our list, you will be ready to get into numerous SQL-worthy job roles like SQL Developer, Business Analyst, BI Reporting Engineer, Data Scientist, Software Engineer, Database Administrator, Quality Assurance Tester, BI Solution Architect and more.

Great Learning has prepared a list of the top 10 SQL interview questions that will help you during your interview.

  • What is SQL?
  • What is a Database?
  • What is DBMS?
  • How to create a table in SQL?
  • How to delete a table in SQL?
  • How to change a table name in SQL?
  • How to create a database in SQL?
  • What is join in SQL?
  • What is Normalization in SQL?
  • How to insert a date in SQL?

Further, This blog is divided into different sections, they are:

Basic SQL Interview Questions SQL Interview Questions for Experienced SQL Interview Questions for Developers SQL Joins Interview Questions Advanced SQL Interview Questions SQL Server Interview Questions PostgreSQL Interview Questions SQL Practice Questions Free Resources to learn SQL

Basic SQL Interview Questions

All set to kickstart your career in SQL? Look no further and start your professional career with these SQL interview questions for freshers. We will start with the basics and slowly move towards slightly advanced questions to set the pace. If you are an experienced professional, this section will help you brush up on your SQL skills.

What is SQL?

The acronym SQL stands for Structured Query Language. It is the typical language used for relational database maintenance and a wide range of data processing tasks. The first SQL database was created in 1970. It is a database language used for operations such as database creation, deletion, retrieval, and row modification. It is occasionally pronounced “sequel.” It can also be used to manage structured data, which is made up of variables called entities and relationships between those entities.

What is Database?

A is a system that helps in collecting, storing and retrieving data. Databases can be complex, and such databases are developed using design and modelling approaches.

What is DBMS?

DBMS stands for Database Management System which is responsible for the creating, updating, and managing of the database.

What is RDBMS? How is it different from DBMS?

RDBMS stands for Relational Database Management System that stores data in the form of a collection of tables, and relations can be defined between the common fields of these tables.

How to create a table in SQL?

The command to create a table in SQL is extremely simple:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

We will start off by giving the keywords, CREATE TABLE, and then we will give the name of the table. After that in braces, we will list out all the columns along with their data types.

For example, if we want to create a simple employee table:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

How to delete a table in SQL?

There are two ways to delete a table from SQL: DROP and TRUNCATE. The DROP TABLE command is used to completely delete the table from the database. This is the command:

DROP TABLE table_name;

The above command will completely delete all the data present in the table along with the table itself.

But if we want to delete only the data present in the table but not the table itself, then we will use the truncate command:

DROP TABLE table_name ;

How to change a table name in SQL?

This is the command to change a table name in SQL:

ALTER TABLE table_name
RENAME TO new_table_name;

We will start off by giving the keywords ALTER TABLE, then we will follow it up by giving the original name of the table, after that, we will give in the keywords RENAME TO and finally, we will give the new table name.

For example, if we want to change the “employee” table to “employee_information”, this will be the command:

ALTER TABLE employee
RENAME TO employee_information;

How to delete a row in SQL?

We will be using the DELETE query to delete existing rows from the table:

DELETE FROM table_name
WHERE [condition];

We will start off by giving the keywords DELETE FROM, then we will give the name of the table, and after that we will give the WHERE clause and give the condition on the basis of which we would want to delete a row.

For example, from the employee table, if we would like to delete all the rows, where the age of the employee is equal to 25, then this will be the command:

DELETE FROM employee
WHERE [age=25];

How to create a database in SQL?

A database is a repository in SQL, which can comprise multiple tables.

This will be the command to create a database in sql:

CREATE DATABASE databasename.

What is Normalization in SQL?

Normalization is used to decompose a larger, complex table into simple and smaller ones. This helps us in removing all the redundant data.

Generally, in a table, we will have a lot of redundant information which is not required, so it is better to divide this complex table into multiple smaller tables which contain only unique information.

First normal form:

A relation schema is in 1NF, if and only if:

  • All attributes in the relation are atomic(indivisible value)
  • And there are no repeating elements or groups of elements.

Second normal form:

A relation is said to be in 2NF, if and only if:

  • It is in 1st Normal Form.
  • No partial dependency exists between non-key attributes and key attributes.

Third Normal form:

A relation R is said to be in 3NF if and only if:

  • It is in 2NF.
  • No transitive dependency exists between non-key attributes and key attributes through another non-key attribute

What is join in SQL?

Joins are used to combine rows from two or more tables, based on a related column between them.

Types of Joins:

• INNER JOIN − Returns rows when there is a match in both tables.

• LEFT JOIN − Returns all rows from the left table, even if there are no matches in the right table.

• RIGHT JOIN − Returns all rows from the right table, even if there are no matches in the left table.

• FULL OUTER JOIN − Returns rows when there is a match in one of the tables.

• SELF JOIN − Used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.

• CARTESIAN JOIN (CROSS JOIN) − Returns the Cartesian product of the sets of records from the two or more joined tables.

Top sql interview questions for 3 years experience

INNER JOIN:

The INNER JOIN creates a new result table by combining column values of two tables (table1 and table2) based upon the join-predicate. The query compares each row of table1 with each row of table2 to find all pairs of rows which satisfy the join-predicate.

SYNTAX:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

0

LEFT JOIN:

The LEFT JOIN returns all the values from the left table, plus matched values from the right table or NULL in case of no matching join predicate.

SYNTAX:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

1

RIGHT JOIN:

The RIGHT JOIN returns all the values from the right table, plus matched values from the left table or NULL in case of no matching join predicate.

SYNTAX:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

2

FULL OUTER JOIN:

The FULL OUTER JOIN combines the results of both left and right outer joins. The joined table will contain all records from both the tables and fill in NULLs for missing matches on either side.

SYNTAX:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

3

SELF JOIN:

The SELF JOIN joins a table to itself; temporarily renaming at least one table in the SQL statement.

SYNTAX:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

4

Joins in SQL

How to insert a date in SQL?

If the RDBMS is MYSQL, this is how we can insert date:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

5

What is Primary Key in SQL?

Primary Key is a constraint in SQL. So, before understanding what exactly is a primary key, let’s understand what exactly is a constraint in SQL. Constraints are the rules enforced on data columns on a table. These are used to limit the type of data that can go into a table. Constraints can either be column level or table level.

Let’s look at the different types of constraints which are present in SQL:

ConstraintDescriptionNOT NULLEnsures that a column cannot have a NULL value.DEFAULTProvides a default value for a column when none is specified.UNIQUEEnsures that all the values in a column are differentPRIMARYUniquely identifies each row/record in a database tableFOREIGNUniquely identifies a row/record in any another database tableCHECKThe CHECK constraint ensures that all values in a column satisfy certain conditions.INDEXUsed to create and retrieve data from the database very quickly.

You can consider the Primary Key constraint to be a combination of UNIQUE and NOT NULL constraint. This means that if a column is set as a primary key, then this particular column cannot have any null values present in it and also all the values present in this column must be unique.

How do I view tables in SQL?

To view tables in SQL, all you need to do is give this command:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

6

What is PL/SQL?

PL SQL stands for Procedural language constructs for Structured Query Language. PL SQL was introduced by Oracle to overcome the limitations of plain sql. So, pl sql adds in procedural language approach to the plain vanilla sql.

One thing to be noted over here is that pl sql is only for oracle databases. If you don’t have an , then you cant work with PL SQL. However, if you wish to learn more about Oracle, you can also take upand enhance your knowledge.

While, with the help of sql, we were able to DDL and DML queries, with the help of PL SQL, we will be able to create functions, triggers and other procedural constructs.

How can I see all tables in SQL?

Different database management systems have different queries to see all the tables.

To see all the tables in MYSQL, we would have to use this query:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

7

This is how we can see all tables in ORACLE:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

8

This is how we can extract all tables in SQL Server:

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

9

What is ETL in SQL?

ETL stands for Extract, Transform and Load. It is a three-step process, where we would have to start off by extracting the data from sources. Once we collate the data from different sources, what we have is raw data. This raw data has to be transformed into the tidy format, which will come in the second phase. Finally, we would have to load this tidy data into tools which would help us to find insights.

How to install SQL?

SQL stands for Structured Query Language and it is not something you can install. To implement sql queries, you would need a relational database management system. There are different varieties of relational database management systems such as:

  • ORACLE
  • MYSQL
  • SQL Server

Hence, to implement sql queries, we would need to install any of these Relational Database Management Systems.

What is the update command in SQL?

The update command comes under the DML(Data Manipulation Langauge) part of sql and is used to update the existing data in the table.

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

0

With this update command, I am changing the last name of the employee.

How to rename column name in SQL Server?

Rename column in SQL: When it comes to SQL Server, it is not possible to rename the column with the help of ALTER TABLE command, we would have to use sp_rename.

What are the types of SQL Queries?

We have four types of SQL Queries:

  • DDL (Data Definition Language): the creation of objects
  • DML (Data Manipulation Language): manipulation of data
  • DCL (Data Control Language): assignment and removal of permissions
  • TCL (Transaction Control Language): saving and restoring changes to a database

Let’s look at the different commands under DDL:

CommandDescriptionCREATECreate objects in the databaseALTERAlters the structure of the database objectDROPDelete objects from the databaseTRUNCATERemove all records from a table permanentlyCOMMENTAdd comments to the data dictionaryRENAMERename an object

Write a Query to display the number of employees working in each region?

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

1

What are Nested Triggers?

Triggers may implement DML by using INSERT, UPDATE, and DELETE statements. These triggers that contain DML and find other triggers for data modification are called Nested Triggers.

Write SQL query to fetch employee names having a salary greater than or equal to 20000 and less than or equal 10000.

By using BETWEEN in the where clause, we can retrieve the Employee Ids of employees with salary >= 20000 and <=10000.

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

2

Given a table Employee having columns empName and empId, what will be the result of the SQL query below? select empName from Employee order by 2 asc;

“Order by 2” is valid when there are at least 2 columns used in SELECT statement. Here this query will throw error because only one column is used in the SELECT statement.

What is OLTP?

OLTP stands for Online Transaction Processing. And is a class of software applications capable of supporting transaction-oriented programs. An essential attribute of an OLTP system is its ability to maintain concurrency.

What is Data Integrity?

Data Integrity is the assurance of accuracy and consistency of data over its entire life-cycle, and is a critical aspect to the design, implementation and usage of any system which stores, processes, or retrieves data. It also defines integrity constraints to enforce business rules on the data when it is entered into an application or a database.

What is OLAP?

OLAP stands for Online Analytical Processing. And a class of software programs which are characterized by relatively low frequency of online transactions. Queries are often too complex and involve a bunch of aggregations.

Find the Constraint information from the table?

There are so many times where user needs to find out the specific constraint information of the table. The following queries are useful, SELECT * From User_Constraints; SELECT * FROM User_Cons_Columns;

Can you get the list of employees with same salary?

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

3

What is an alternative for the TOP clause in SQL?

1. ROWCOUNT function 2. Set rowcount 3 3. Select * from employee order by empid desc Set rowcount 0

Will the following statement gives an error or 0 as output? SELECT AVG (NULL)

Error. Operand data type NULL is invalid for the Avg operator.

What is the Cartesian product of the table?

The output of Cross Join is called a Cartesian product. It returns rows combining each row from the first table with each row of the second table. For Example, if we join two tables having 15 and 20 columns the Cartesian product of two tables will be 15×20=300 rows.

What is a schema in SQL?

Our database comprises of a lot of different entities such as tables, stored procedures, functions, database owners and so on. To make sense of how all these different entities interact, we would need the help of schema. So, you can consider schema to be the logical relationship between all the different entities which are present in the database.

Once we have a clear understanding of the schema, this helps in a lot of ways:

  • We can decide which user has access to which tables in the database.
  • We can modify or add new relationships between different entities in the database.

Overall, you can consider a schema to be a blueprint for the database, which will give you the complete picture of how different objects interact with each other and which users have access to different entities.

How to delete a column in SQL?

To delete a column in SQL we will be using DROP COLUMN method:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

4

We will start off by giving the keywords ALTER TABLE, then we will give the name of the table, following which we will give the keywords DROP COLUMN and finally give the name of the column which we would want to remove.

What is a unique key in SQL?

Unique Key is a constraint in SQL. So, before understanding what exactly is a primary key, let’s understand what exactly is a constraint in SQL. Constraints are the rules enforced on data columns on a table. These are used to limit the type of data that can go into a table. Constraints can either be column level or table level.

Unique Key:

Whenever we give the constraint of unique key to a column, this would mean that the column cannot have any duplicate values present in it. In other words, all the records which are present in this column have to be unique.

How to implement multiple conditions using the WHERE clause?

We can implement multiple conditions using AND, OR operators:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

5

In the above command, we are giving two conditions. The condition ensures that we extract only those records where the first name of the employee is ‘Steven’ and the second condition ensures that the salary of the employee is less than $10,000. In other words, we are extracting only those records, where the employee’s first name is ‘Steven’ and this person’s salary should be less than $10,000.

What is the difference between SQL vs PL/SQL?

BASIS FOR COMPARISONSQLPL/SQLBasicIn SQL you can execute a single query or a command at a time.In PL/SQL you can execute a block of code at a time.Full formStructured Query LanguageProcedural Language, an extension of SQL.PurposeIt is like a source of data that is to be displayed.It is a language that creates an application that displays data acquired by SQL.WritesIn SQL you can write queries and commands using DDL, DML statements.In PL/SQL you can write a block of code that has procedures, functions, packages or variables, etc.UseUsing SQL, you can retrieve, modify, add, delete, or manipulate the data in the database.Using PL/SQL, you can create applications or server pages that display the information obtained from SQL in a proper format.EmbedYou can embed SQL statements in PL/SQL.You can not embed PL/SQL in SQL

What is the difference between SQL having vs where?

  1. No.Where ClauseHaving Clause1The WHERE clause specifies the criteria which individual records must meet to be selected by a query. It can be used without the GROUP by clauseThe HAVING clause cannot be used without the GROUP BY clause2The WHERE clause selects rows before groupingThe HAVING clause selects rows after grouping3The WHERE clause cannot contain aggregate functionsThe HAVING clause can contain aggregate functions4WHERE clause is used to impose a condition on SELECT statement as well as single row function and is used before GROUP BY clauseHAVING clause is used to impose a condition on GROUP Function and is used after GROUP BY clause in the query5SELECT Column,AVG(Column_nmae)FROM Table_name WHERE Column > value GROUP BY Column_nmaeSELECT Columnq, AVG(Coulmn_nmae)FROM Table_name WHERE Column > value GROUP BY Column_nmae Having column_name>or

SQL Interview Questions for Experienced

Planning to switch your career to SQL or just need to upgrade your position? Whatever your reason, this section will better prepare you for the SQL interview. We have compiled a set of advanced SQL questions that may be frequently asked during the interview.

What is SQL injection?

SQL injection is a hacking technique which is widely used by black-hat hackers to steal data from your tables or databases. Let’s say, if you go to a website and give in your user information and password, the hacker would add some malicious code over there such that, he can get the user information and password directly from the database. If your database contains any vital information, it is always better to keep it secure from SQL injection attacks.

What is a trigger in SQL?

A trigger is a stored program in a database which automatically gives responses to an event of DML operations done by inserting, update, or delete. In other words, is nothing but an auditor of events happening across all database tables.

Let’s look at an example of a trigger:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

6

How to insert multiple rows in SQL?

To insert multiple rows in SQL we can follow the below syntax:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

7

We start off by giving the keywords INSERT INTO then we give the name of the table into which we would want to insert the values. We will follow it up with the list of the columns, for which we would have to add the values. Then we will give in the VALUES keyword and finally, we will give the list of values.

Here is an example of the same:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

8

In the above example, we are inserting multiple records into the table called employees.

How to find the nth highest salary in SQL?

This is how we can find the nth highest salary in SQL SERVER using TOP keyword:

CREATE TABLE employee (
  name varchar(25),
  age int,
  gender varchar(25),
   ....
);

9

This is how we can find the nth highest salary in MYSQL using LIMIT keyword:

DROP TABLE table_name;

0

How to copy table in SQL?

We can use the SELECT INTO statement to copy data from one table to another. Either we can copy all the data or only some specific columns.

This is how we can copy all the columns into a new table:

DROP TABLE table_name;

1

If we want to copy only some specific columns, we can do it this way:

DROP TABLE table_name;

2

How to add a new column in SQL?

We can add a new column in SQL with the help of alter command:

DROP TABLE table_name;

3

This command helps us to add a new column named as contact in the employees table.

How to use LIKE in SQL?

The LIKE operator checks if an attribute value matches a given string pattern. Here is an example of LIKE operator

DROP TABLE table_name;

4

With this command, we will be able to extract all the records where the first name is like “Steven”.

Yes, SQL server drops all related objects, which exists inside a table like constraints, indexex, columns, defaults etc. But dropping a table will not drop views and sorted procedures as they exist outside the table.

Can we disable a trigger? If yes, How?

Yes, we can disable a single trigger on the database by using “DISABLE TRIGGER triggerName ON<>. We also have an option to disable all the trigger by using, “DISABLE Trigger ALL ON ALL SERVER”.

What is a Live Lock?

A live lock is one where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keep interferring. A live lock also occurs when read transactions create a table or page.

How to fetch alternate records from a table?

Records can be fetched for both Odd and Even row numbers – To display even numbers –

DROP TABLE table_name;

5

To display odd numbers –

DROP TABLE table_name;

6

Define COMMIT and give an example?

When a COMMIT is used in a transaction, all changes made in the transaction are written into the database permanently.

Example:

DROP TABLE table_name;

7

The above example deletes a job candidate in a SQL server.

Can you join the table by itself?

A table can be joined to itself using self join, when you want to create a result set that joins records in a table with other records in the same table.

Explain Equi join with an example.

When two or more tables have been joined using equal to operator then this category is called an equi join. Just we need to concentrate on the condition is equal to (=) between the columns in the table.

Example:

DROP TABLE table_name;

8

How do we avoid getting duplicate entries in a query?

The SELECT DISTINCT is used to get distinct data from tables using a query. The below SQL query selects only the DISTINCT values from the “Country” column in the “Customers” table:

DROP TABLE table_name;

9

How can you create an empty table from an existing table?

Lets take an example:

DROP TABLE table_name ;

0

Here, we are copying the student table to another table with the same structure with no rows copied.

Write a Query to display odd records from student table?

DROP TABLE table_name ;

1

Explain Non-Equi Join with an example?

When two or more tables are joining without equal to condition, then that join is known as Non Equi Join. Any operator can be used here, that is <>,!=,<,>,Between.

Example:

DROP TABLE table_name ;

2

How can you delete duplicate records in a table with no primary key?

By using the SET ROWCOUNT command. It limits the number of records affected by a command. Let’s take an example, if you have 2 duplicate rows, you would SET ROWCOUNT 1, execute DELETE command and then SET ROWCOUNT 0.

Difference between NVL and NVL2 functions?

Both the NVL(exp1, exp2) and NVL2(exp1, exp2, exp3) functions check the value exp1 to see if it is null. With the NVL(exp1, exp2) function, if exp1 is not null, then the value of exp1 is returned; otherwise, the value of exp2 is returned, but case to the same data type as that of exp1. With the NVL2(exp1, exp2, exp3) function, if exp1 is not null, then exp2 is returned; otherwise, the value of exp3 is returned.

What is the difference between clustered and non-clustered indexes?

  1. Clustered indexes can be read rapidly rather than non-clustered indexes.
  2. Clustered indexes store data physically in the table or view whereas, non-clustered indexes do not store data in the table as it has separate structure from the data row.

What does this query says? GRANT privilege_name ON object_name TO {user_name|PUBLIC|role_name} [WITH GRANT OPTION];

The given syntax indicates that the user can grant access to another user too.

Where MyISAM table is stored?

Each MyISAM table is stored on disk in three files.

  1. The “.frm” file stores the table definition.
  2. The data file has a ‘.MYD’ (MYData) extension.
  3. The index file has a ‘.MYI’ (MYIndex) extension.

What does myisamchk do?

It compresses the MyISAM tables, which reduces their disk or memory usage.

What is ISAM?

ISAM is abbreviated as Indexed Sequential Access Method. It was developed by IBM to store and retrieve data on secondary storage systems like tapes.

What is Database White box testing?

White box testing includes: Database Consistency and ACID properties Database triggers and logical views Decision Coverage, Condition Coverage, and Statement Coverage Database Tables, Data Model, and Database Schema Referential integrity rules.

What are the different types of SQL sandbox?

There are 3 different types of SQL sandbox:

  • Safe Access Sandbox: Here a user can perform SQL operations such as creating stored procedures, triggers etc. but cannot have access to the memory as well as cannot create files.
  • External Access Sandbox: Users can access files without having the right to manipulate the memory allocation.
  • Unsafe Access Sandbox: This contains untrusted codes where a user can have access to memory.

What is Database Black Box Testing?

This testing involves:

  • Data Mapping
  • Data stored and retrieved
  • Use of Black Box testing techniques such as Equivalence Partitioning and Boundary Value Analysis (BVA).

Explain Right Outer Join with Example?

This join is usable, when user wants all the records from Right table (Second table) and only equal or matching records from First or left table. The unmatched records are considered as null records. Example: Select t1.col1,t2.col2….t ‘n’col ‘n.’. from table1 t1,table2 t2 where t1.col(+)=t2.col;

What is a Subquery?

A SubQuery is a SQL query nested into a larger query. Example: SELECT employeeID, firstName, lastName FROM employees WHERE departmentID IN (SELECT departmentID FROM departments WHERE locationID = 2000) ORDER BY firstName, lastName;

SQL Interview Questions for Developers

How to find duplicate records in SQL?

There are multiple ways to find duplicate records in SQL. Let’s see how can we find duplicate records using group by:

DROP TABLE table_name ;

3

We can also find duplicates in the table using rank:

DROP TABLE table_name ;

4

What is Case WHEN in SQL?

If you have knowledge about other programming languages, then you’d have learnt about if-else statements. You can consider Case WHEN to be analogous to that.

In Case WHEN, there will be multiple conditions and we will choose something on the basis of these conditions.

Here is the syntax for CASE WHEN:

DROP TABLE table_name ;

5

We start off by giving the CASE keyword, then we follow it up by giving multiple WHEN, THEN statements.

How to find 2nd highest salary in SQL?

Below is the syntax to find 2nd highest salary in SQL:

DROP TABLE table_name ;

6

How to delete duplicate rows in SQL?

There are multiple ways to delete duplicate records in SQL.

Below is the code to delete duplicate records using rank:

DROP TABLE table_name ;

7

Below is the syntax to delete duplicate records using groupby and min:

DROP TABLE table_name ;

8

What is cursor in SQL?

Cursors in SQL are used to store database tables. There are two types of cursors:

  • Implicit Cursor
  • Explicit Cursor

Implicit Cursor:

These implicit cursors are default cursors which are automatically created. A user cannot create an implicit cursor.

Explicit Cursor:

Explicit cursors are user-defined cursors. This is the syntax to create explicit cursor:

DROP TABLE table_name ;

9

We start off by giving by keyword DECLARE, then we give the name of the cursor, after that we give the keywords CURSOR FOR SELECT * FROM, finally, we give in the name of the table.

How to create a stored procedure using SQL Server?

If you have worked with other languages, then you would know about the concept of Functions. You can consider stored procedures in SQL to be analogous to functions in other languages. This means that we can store a SQL statement as a stored procedure and this stored procedure can be invoked whenever we want.

This is the syntax to create a stored procedure:

ALTER TABLE table_name
RENAME TO new_table_name;

0

We start off by giving the keywords CREATE PROCEDURE, then we go ahead and give the name of this stored procedure. After that, we give the AS keyword and follow it up with the SQL query, which we want as a stored procedure. Finally, we give the GO keyword.

Once, we create the stored procedure, we can invoke it this way:

ALTER TABLE table_name
RENAME TO new_table_name;

1

We will give in the keyword EXEC and then give the name of the stored procedure.

Let’s look at an example of a stored procedure:

ALTER TABLE table_name
RENAME TO new_table_name;

2

In the above command, we are creating a stored procedure which will help us to extract all the employees who belong to a particular location.

ALTER TABLE table_name
RENAME TO new_table_name;

3

With this, we are extracting all the employees who belong to Boston.

How to create an index in SQL?

We can create an index using this command:

ALTER TABLE table_name
RENAME TO new_table_name;

4

We start off by giving the keywords CREATE INDEX and then we will follow it up with the name of the index, after that we will give the ON keyword. Then, we will give the name of the table on which we would want to create this index. Finally, in parenthesis, we will list out all the columns which will have the index. Let’s look at an example:

ALTER TABLE table_name
RENAME TO new_table_name;

5

In the above example, we are creating an index called a salary on top of the ‘Salary’ column of the ‘Employees’ table.

Now, let’s see how can we create a unique index:

ALTER TABLE table_name
RENAME TO new_table_name;

6

We start off with the keywords CREATE UNIQUE INDEX, then give in the name of the index, after that, we will give the ON keyword and follow it up with the name of the table. Finally, in parenthesis, we will give the list of the columns which on which we would want this unique index.

How to change the column data type in SQL?

We can change the data type of the column using the alter table. This will be the command:

ALTER TABLE table_name
RENAME TO new_table_name;

7

We start off by giving the keywords ALTER TABLE, then we will give in the name of the table. After that, we will give in the keywords MODIFY COLUMN. Going ahead, we will give in the name of the column for which we would want to change the datatype and finally we will give in the data type to which we would want to change.

How to Rename Column Name in SQL?

Difference between SQL and NoSQL databases?

SQL stands for structured query language and is majorly used to query data from relational databases. When we talk about a SQL database, it will be a relational database.

But when it comes to the NoSQL databases, we will be working with non-relational databases.

Want to learn more about NoSQL databases? Check out the NoSQL course.

SQL Joins Interview Questions

How to change column name in SQL?

The command to change the name of a column is different in different RDBMS.

This is the command to change the name of a column in MYSQL:

ALTER TABLE table_name
RENAME TO new_table_name;

8

IN MYSQL, we will start off by using the ALTER TABLE keywords, then we will give in the name of the table. After that, we will use the CHANGE keyword and give in the original name of the column, following which we will give the name to which we would want to rename our column.

This is the command to change the name of a column in ORACLE:

ALTER TABLE table_name
RENAME TO new_table_name;

9

In ORACLE, we will start off by using the ALTER TABLE keywords, then we will give in the name of the table. After that, we will use the RENAME COLUMN keywords and give in the original name of the column, following which we will give the TO keyword and finally give the name to which we would like to rename our column.

When it comes to SQL Server, it is not possible to rename the column with the help of ALTER TABLE command, we would have to use sp_rename.

What is a view in SQL?

A view is a database object that is created using a Select Query with complex logic, so views are said to be a logical representation of the physical data, i.e Views behave like a physical table and users can use them as database objects in any part of SQL queries.

Let’s look at the types of Views:

  • Simple View
  • Complex View
  • Inline View
  • Materialized View

Simple View:

Simple views are created with a select query written using a single table. Below is the command to create a simple view:

ALTER TABLE employee
RENAME TO employee_information;

0

Complex View:

ALTER TABLE employee
RENAME TO employee_information;

1

Inline View:

A subquery is also called an inline view if and only if it is called in FROM clause of a SELECT query.

ALTER TABLE employee
RENAME TO employee_information;

2

Top sql interview questions for 3 years experience

How to drop a column in SQL?

To drop a column in SQL, we will be using this command:

ALTER TABLE employee
RENAME TO employee_information;

3

We will start off by giving the keywords ALTER TABLE, then we will give the name of the table, following which we will give the keywords DROP COLUMN and finally give the name of the column which we would want to remove.

How to use BETWEEN in SQL?

The BETWEEN operator checks an attribute value within a range. Here is an example of BETWEEN operator:

ALTER TABLE employee
RENAME TO employee_information;

4

With this command, we will be able to extract all the records where the salary of the employee is between 10000 and 20000.

Advanced SQL Interview Questions

What are the subsets of SQL?

  • DDL (Data Definition Language): Used to define the data structure it consists of the commands like CREATE, ALTER, DROP, etc.
  • DML (Data Manipulation Language): Used to manipulate already existing data in the database, commands like SELECT, UPDATE, INSERT
  • DCL (Data Control Language): Used to control access to data in the database, commands like GRANT, REVOKE.

Difference between CHAR and VARCHAR2 datatype in SQL?

CHAR is used to store fixed-length character strings, and VARCHAR2 is used to store variable-length character strings.

How to sort a column using a column alias?

By using the column alias in the ORDER BY instead of where clause for sorting

Difference between COALESCE() & ISNULL() ?

COALESCE() accepts two or more parameters, one can apply 2 or as many parameters but it returns only the first non NULL parameter.

ISNULL() accepts only 2 parameters.

The first parameter is checked for a NULL value, if it is NULL then the 2nd parameter is returned, otherwise, it returns the first parameter.

What is “Trigger” in SQL?

A trigger allows you to execute a batch of SQL code when an insert,update or delete command is run against a specific table as Trigger is said to be the set of actions that are performed whenever commands like insert, update or delete are given.

Write a Query to display employee details along with age.

ALTER TABLE employee
RENAME TO employee_information;

5

Write a Query to display employee details along with age?

ALTER TABLE employee
RENAME TO employee_information;

6

Write an SQL query to get the third maximum salary of an employee from a table named employee_table.

ALTER TABLE employee
RENAME TO employee_information;

7

What are aggregate and scalar functions?

Aggregate functions are used to evaluate mathematical calculations and return single values. This can be calculated from the columns in a table. Scalar functions return a single value based on input value.

Example -. Aggregate – max(), count – Calculated with respect to numeric. Scalar – UCASE(), NOW() – Calculated with respect to strings.

What is a deadlock?

It is an unwanted situation where two or more transactions are waiting indefinitely for one another to release the locks.

Explain left outer join with example.

Left outer join is useful if you want all the records from the left table(first table) and only matching records from 2nd table. The unmatched records are null records. Example: Left outer join with “+” operator Select t1.col1,t2.col2….t ‘n’col ‘n.’. from table1 t1,table2 t2 where t1.col=t2.col(+);

What is SQL injection?

SQL injection is a code injection technique used to hack data-driven applications.

What is a UNION operator?

The UNION operator combines the results of two or more Select statements by removing duplicate rows. The columns and the data types must be the same in the SELECT statements.

Explain SQL Constraints.

SQL Constraints are used to specify the rules of data type in a table. They can be specified while creating and altering the table. The following are the constraints in SQL: NOT NULL CHECK DEFAULT UNIQUE PRIMARY KEY FOREIGN KEY

What is the ALIAS command?

This command provides another name to a table or a column. It can be used in the WHERE clause of a SQL query using the “as” keyword.

What are Group Functions? Why do we need them?

Group functions work on a set of rows and return a single result per group. The popularly used group functions are AVG, MAX, MIN, SUM, VARIANCE, and COUNT.

How can dynamic SQL be executed?

  • By executing the query with parameters
  • By using EXEC
  • By using sp_executesql

What is the usage of NVL() function?

This function is used to convert the NULL value to the other value.

Write a Query to display employee details belongs to ECE department?

SELECT EmpNo, EmpName, Salary FROM employee WHERE deptNo in (select deptNo from dept where deptName = ‘ECE’)

What are the main differences between

temp tables and @table variables and which one is preferred?

1. SQL server can create column statistics on

temp tables.

2. Indexes can be created on

temp tables

3. @table variables are stored in memory up to a certain threshold

What is CLAUSE?

SQL clause is defined to limit the result set by providing conditions to the query. This usually filters some rows from the whole set of records. Example – Query that has WHERE condition.

What is a recursive stored procedure?

A stored procedure calls by itself until it reaches some boundary condition. This recursive function or procedure helps programmers to use the same set of code any number of times.

What does the BCP command do?

The Bulk Copy is a utility or a tool that exports/imports data from a table into a file and vice versa.

What is a Cross Join?

In SQL cross join, a combination of every row from the two tables is included in the result set. This is also called cross product set. For example, if table A has ten rows and table B has 20 rows, the result set will have 10 * 20 = 200 rows provided there is a NOWHERE clause in the SQL statement.

Which operator is used in query for pattern matching?

LIKE operator is used for pattern matching, and it can be used as- 1. % – Matches zero or more characters. 2. _(Underscore) – Matching exactly one character.

Write a SQL query to get the current date?

SELECT CURDATE();

State the case manipulation functions in SQL?

  • LOWER: converts all the characters to lowercase.
  • UPPER: converts all the characters to uppercase.
  • INITCAP: converts the initial character of each word to uppercase

How to add a column to an existing table?

ALTER TABLE Department ADD (Gender, M, F)

Define lock escalation?

A query first takes the lowest level lock possible with the smallest row level. When too many rows are locked, the lock is escalated to a range or page lock. If too many pages are locked, it may escalate to a table lock.

How to store Videos inside SQL Server table?

By using FILESTREAM datatype, which was introduced in SQL Server 2008.

State the order of SQL SELECT?

The order of SQL SELECT clauses is: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY. Only the SELECT and FROM clauses are mandatory.

What is the difference between IN and EXISTS?

IN: Works on List result set Doesn’t work on subqueries resulting in Virtual tables with multiple columns Compares every value in the result list.

Exists: Works on Virtual tables Is used with co-related queries Exits comparison when the match is found

How do you copy data from one table to another table?

INSERT INTO table2 (column1, column2, column3, …) SELECT column1, column2, column3, … FROM table1 WHERE condition;

List the ACID properties that make sure that the database transactions are processed

ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties that guarantee that database transactions are processed reliably.

What will be the output of the following Query, provided the employee table has 10 records?

BEGIN TRAN TRUNCATE TABLE Employees ROLLBACK SELECT * FROM Employees

This query will return 10 records as TRUNCATE was executed in the transaction. TRUNCATE does not itself keep a log but BEGIN TRANSACTION keeps track of the TRUNCATE command.

What do you mean by Stored Procedures? How do we use it?

A stored procedure is a collection of SQL statements that can be used as a function to access the database. We can create these stored procedures earlier before using it and can execute them wherever required by applying some conditional logic to it. Stored procedures are also used to reduce network traffic and improve performance.

What does GRANT command do?

This command is used to provide database access to users other than the administrator in SQL privileges.

What does the First normal form do?

First Normal Form (1NF): It removes all duplicate columns from the table. It creates a table for related data and identifies unique column values.

How to add e record to the table?

INSERT syntax is used to add a record to the table. INSERT into table_name VALUES (value1, value2..);

What are the different tables present in MySQL?

There are 5 tables present in MYSQL.

  • MyISAM
  • Heap
  • Merge
  • INNO DB
  • ISAM

What is BLOB and TEXT in MySQL?

BLOB stands for the large binary objects. It is used to hold a variable amount of data. TEXT is a case-insensitive BLOB. TEXT values are non-binary strings (character strings).

What is the use of mysql_close()?

Mysql_close() cannot be used to close the persistent connection. Though it can be used to close a connection opened by mysql_connect().

Write a query to find out the data between ranges?

In day-to-day activities, the user needs to find out the data between some range. To achieve this user needs to use Between..and operator or Greater than and less than the operator.

ALTER TABLE employee
RENAME TO employee_information;

8

How to calculate the number of rows in a table without using the count function?

There are so many system tables which are very important. Using the system table user can count the number of rows in the table. following query is helpful in that case, Select table_name, num_rows from user_tables where table_name=’Employee’;

What is wrong with the following query? SELECT empName FROM employee WHERE salary <> 6000

The following query will not fetch a record with the salary of 6000 but also will skip the record with NULL.

Will the following statements execute? if yes what will be output? SELECT NULL+1 SELECT NULL+’1′

Yes, no error. The output will be NULL. Performing any operation on NULL will get the NULL result.

SQL Server Interview Questions

What is an SQL server?

SQL server has stayed on top as one of the most popular database management products ever since its first release in 1989 by Microsoft Corporation. The product is used across industries to store and process large volumes of data. It was primarily built to store and process data that is built on a relational model of data.

SQL Server is widely used for data analysis and also scaling up of data. SQL Server can be used in conjunction with Big Data tools such as Hadoop.

SQL Server can be used to process data from various data sources such as Excel, Table, .Net Framework application, etc.

How to install SQL Server?

  • Click on the below SQL Server official release link to access the latest version: https://www.microsoft.com/en-in/sql-server/sql-server-downloads
  • Select the type of SQL Server edition that you want to install. SQL Server can be used on a Cloud Platform or as an open-source edition(Express or Developer) in your local computer system.
  • Click on the Download Now button.
  • Save the .exe file on your system. Right-click on the .exe file and click on Open.
  • Click on ‘Yes’ to allow the changes to be made on your system and have SQL Server Installed.
  • Once the installation is complete, restart your system, if required, and launch the SQL Server Management Studio application from the START menu.

How to create a stored procedure in SQL Server?

A Stored Procedure is nothing but a frequently used SQL query. Queries such as a SELECT query, which would often be used to retrieve a set of information many times within a database, can be saved as a Stored Procedure. The Stored Procedure, when called, executes the SQL query saved within the Stored Procedure.

Syntax to create a Stored Proc:

ALTER TABLE employee
RENAME TO employee_information;

9

Stored procedures can be user-defined or built-in. Various parameters can be passed onto a Stored Procedure.

How to install SQL Server 2008?

  • Click on the below SQL Server official release link: https://www.microsoft.com/en-in/sql-server/sql-server-downloads
  • Click on the search icon and type in – SQL Server 2008 download
  • Click on the result link to download and save SQL Server 2008.
  • Select the type of SQL Server edition that you want to install. SQL Server can be used on a Cloud Platform or as an open-source edition(Express or Developer) in your local computer system.
  • Click on the Download Now button.
  • Save the .exe file on your system. Right-click on the .exe file and click on Open.
  • Click on ‘Yes’ to allow the changes to be made on your system and have SQL Server installed.
  • Once the installation is complete, restart your system, if required, and launch the SQL Server Management Studio application.

How to install SQL Server 2017?

  • Click on the below SQL Server official release link: https://www.microsoft.com/en-in/sql-server/sql-server-downloads
  • Click on the search icon and type in – SQL Server 2017 download
  • Click on the result link to download and save SQL Server 2017.
  • Select the type of SQL Server edition that you want to install. SQL Server can be used on a Cloud Platform or as an open-source edition(Express or Developer) in your local computer system.
  • Click on the Download Now button.
  • Save the .exe file on your system. Right-click on the .exe file and click on Open.
  • Click on ‘Yes’ to allow the changes to be made on your system and have SQL Server installed.
  • Once the installation is complete, restart your system, if required, and launch the SQL Server Management Studio application from the START menu.

How to restore the database in SQL Server?

Launch the SQL Server Management Studio application and from the Object Explorer window pane, right-click on Databases and click on Restore. This would automatically restore the database.

How to install SQL Server 2014?

  • Click on the below SQL Server official release link: https://www.microsoft.com/en-in/sql-server/sql-server-downloads
  • Click on the search icon and type in – SQL Server 2014 download
  • Click on the result link to download and save SQL Server 2014.
  • Select the type of SQL Server edition that you want to install. SQL Server can be used on a Cloud Platform or as an open-source edition(Express or Developer) in your local computer system.
  • Click on the Download Now button.
  • Save the .exe file on your system. Right-click on the .exe file and click on Open.
  • Click on ‘Yes’ to allow the changes to be made on your system and have SQL Server Installed.
  • Once the installation is complete, restart your system, if required, and launch the SQL Server Management Studio application from the START menu.

How to get the connection string from SQL Server?

Launch the SQL Server Management Studio. Go to the Database for which you require the Connection string. Right-click on the database and click on Properties. In the Properties window that is displayed, you can view the Connection String property.

Connection strings help connect databases to another staging database or any external source of data.

How to install SQL Server 2012?

  • Click on the below SQL Server official release link: https://www.microsoft.com/en-in/sql-server/sql-server-downloads
  • Click on the search icon and type in – SQL Server 2012 download
  • Click on the result link to download and save SQL Server 2012.
  • Select the type of SQL Server edition that you want to install. SQL Server can be used on a Cloud Platform or as an open-source edition(Express or Developer) in your local computer system.
  • Click on the Download Now button.
  • Save the .exe file on your system. Right-click on the .exe file and click on Open.
  • Click on ‘Yes’ to allow the changes to be made on your system and have SQL Server Installed.
  • Once the installation is complete, restart your system, if required, and launch the SQL Server Management Studio application from the START menu.

What is cte in SQL Server?

CTEs are Common Table Expressions that are used to create temporary result tables from which data can be retrieved/ used. The standard syntax for a CTE with a SELECT statement is:

DELETE FROM table_name
WHERE [condition];

0

Few examples of CTEs are given below:

Query to find the 10 highest salaries.

with result as

DELETE FROM table_name
WHERE [condition];

1

Query to find the 2nd highest salary

with the result as

DELETE FROM table_name
WHERE [condition];

2

In this way, CTEs can be used to find the nth highest salary within an organisation.

How to change the SQL Server password?

Launch your SQL Server Management Studio. Click on the Database connection for which you want to change the login password. Click on Security from the options that get displayed.

Click on Logins and open your database connection. Type in the new password for login and click on ‘OK’ to apply the changes.

How to delete duplicate records in SQL Server?

Select the duplicate records in a table HAVING COUNT(*)>1

Add a delete statement to delete the duplicate records.

Sample Query to find the duplicate records in a table-

DELETE FROM table_name
WHERE [condition];

3

How to uninstall SQL Server?

In Windows 10, go to the START menu and locate the SQL Server.

Right-click and select uninstall to uninstall the application.

How to check SQL Server version?

You can run the below query to view the current version of SQL Server that you are using.

How to rename column name in SQL Server?

From the Object Explorer window pane, go to the table where the column is present and choose Design. Under the Column Name, select the name you want to rename and enter the new name. Go to the File menu and click Save.

What is the stored procedure in SQL Server?

A Stored Procedure is nothing but a frequently used SQL query. Queries such as a SELECT query, which would often be used to retrieve a set of information many times within a database, can be saved as a Stored Procedure. The Stored Procedure, when called, executes the SQL query saved within the Stored Procedure.

Syntax to create a Stored Proc:

ALTER TABLE employee
RENAME TO employee_information;

9

You can execute the Stored Proc by using the command Exec Procedure_Name;

How to create a database in SQL Server?

After installing the required version of SQL Server, it is easy to create new databases and maintain them.

  1. Launch the SQL Server Management Studio
  2. In the Object Explorer window pane, right-click on Databases and select ‘New Database’
  3. Enter the Database Name and click on ‘Ok’.
  4. Voila! Your new database is ready for use.

What is an index in SQL Server?

Indexes are database objects which help in retrieving records quickly and more efficiently. Column indexes can be created on both Tables and Views. By declaring a Column as an index within a table/ view, the user can access those records quickly by executing the index. Indexes with more than one column are called Clustered indexes.

Syntax:

DELETE FROM table_name
WHERE [condition];

5

The syntax to drop an Index is DROP INDEX INDEX_NAME;

Indexes are known to improve the efficiency of SQL Select queries.

How to create the table in SQL Server?

Tables are the fundamental storage objects within a database. A table is usually made up of

Rows and Columns. The below syntax can be used to create a new table with 3 columns.

DELETE FROM table_name
WHERE [condition];

6

Alternatively, you can right-click on Table in the Object Explorer window pane and select ‘New -> Table’.

You can also define the type of Primary/ Foreign/ Check constraint when creating a table.

How to connect to SQL Server?

  • Launch the SQL Server Management Studio from the START menu.
  • In the dialogue box shown below, select the Server Type as Database Engine and Server Name as the name of your laptop/ desktop system.
  • Select the appropriate Authentication type and click on the Connect button.
  • A secure connection would be established, and the list of the available Databases will be loaded in the Object Explorer window pane.

How to delete duplicate rows in SQL Server?

Select the duplicate records in a table HAVING COUNT(*)>1

Add a delete statement to delete the duplicate records.

Sample Query to find the duplicate records in a table –

DELETE FROM table_name
WHERE [condition];

7

How to download SQL Server?

The Express and Developer versions (open-source versions) of the latest SQL Server release can be downloaded from the official Microsoft website. The link is given below for reference. https://www.microsoft.com/en-in/sql-server/sql-server-downloads

How to connect SQL Server management studio to the local database?

  • Launch the SQL Server Management Studio from the START menu.
  • In the dialogue box shown below, select the Server Type as Database Engine and Server Name as the name of your laptop/ desktop system and click on the Connect button.
  • Select the Authentication as ‘Windows Authentication.
  • A secure connection would be established, and the list of the available Databases will be loaded in the Object Explorer window pane.

How to download SQL Server 2014?

  • Both the Express and Developer versions (free editions) of SQL Server can be downloaded from the official Microsoft website. The link is given below for reference.
  • Click on the link below: https://www.microsoft.com/en-in/sql-server/sql-server-downloads
  • Click on the search icon and type in – SQL Server 2014 download
  • Click on the result link to download and save SQL Server 2014.

How to uninstall SQL Server 2014?

From the START menu, type SQL Server. Right-click on the app and select uninstall to uninstall the application from your system. Restart the system, if required, for the changes to get affected.

How to find server names in SQL Server?

Run the query SELECT @@version; to find the version and name of the SQL Server you are using.

How to start SQL Server?

Launch the SQL Server Management Studio from the START menu. Login using Windows Authentication. In the Object Explorer window pane, you can view the list of databases and corresponding objects.

What is the case when in SQL Server?

Case When statements in SQL are used to run through many conditions and to return a value when one such condition is met. If none of the conditions is met in the When statements, then the value mentioned in the Else statement is returned.

Syntax:

DELETE FROM table_name
WHERE [condition];

8

Sample query:

HOW MANY HEAD OFFICES/ BRANCHES ARE THERE IN CANADA

DELETE FROM table_name
WHERE [condition];

9

How to install SQL Server management studio?

Launch Google and in the Search toolbar, type in SQL Server Management Studio download.

Go to the routed website and click on the link to download. Once the download is complete, open the .exe file to install the content of the file. Once the installation is complete, refresh or restart the system, as required.

Alternatively, once SQL Server is installed and launched, it will prompt the user with an option to launch SQ Server Management Studio.

How to write a stored procedure in SQL Server?

A Stored Procedure is nothing but a frequently used SQL query. Queries such as a SELECT query, which would often be used to retrieve a set of information many times within a database, can be saved as a Stored Procedure. The Stored Procedure, when called, executes the SQL query saved within the Stored Procedure.

Syntax to create a Stored Proc:

ALTER TABLE employee
RENAME TO employee_information;

9

You can execute the Stored Proc by using the command Exec Procedure_Name;

How to open SQL Server?

Launch the SQL Server Management Studio from the START menu. Login using Windows Authentication. In the Object Explorer window pane, you can view the list of databases and corresponding objects.

How to use SQL Server?

SQL Server is used to retrieve and process various data that is built on a relational model.

Some of the common actions that can be taken on the data are CREATE, DELETE, INSERT, UPDATE, SELECT, REVOKE, etc.

SQL Server can also be used to import and export data from different data sources. SQL Server can also be connected to various other databases/ .Net frameworks using Connection Strings.

SQL Server can also be used in conjunction with Big Data tools like Hadoop.

What is a function in SQL Server?

Functions are pre-written codes that return a value and which help the user achieve a particular task concerning viewing, manipulating, and processing data.

Examples of a few functions are:

AGGREGATE FUNCTIONS:

  • MIN()- Returns the minimum value
  • MAX()- Returns the maximum value
  • AVG()- Returns the average value
  • COUNT()

STRING FUNCTIONS:

  • COALESCE()
  • CAST()
  • CONCAT()
  • SUBSTRING()

DATE FUNCTIONS:

  • GETDATE()
  • DATEADD()
  • DATEDIFF()

There are many types of functions such as Aggregate Functions, Date Functions, String Functions, Mathematical functions, etc.

How to find nth highest salary in SQL Server without using a subquery

Query to find the 10 highest salaries. For up-gradation of the b10 band.

with result as

DELETE FROM employee
WHERE [age=25];

1

Query to find the 2nd highest salary

with the result as

DELETE FROM employee
WHERE [age=25];

2

In this way, by replacing the salary rank value, we can find the nth highest salary in any organisation.

How to install SQL Server in Windows 10?

DELETE FROM employee
WHERE [age=25];

3

How to create a temp table in SQL Server?

Temporary tables can be used to retain the structure and a subset of data from the original table from which they were derived.

Syntax:

DELETE FROM employee
WHERE [age=25];

4

Temporary tables do not occupy any physical memory and can be used to retrieve data faster.

PostgreSQL Interview Questions

What is PostgreSQL?

PostgreSQL is one of the most widely and popularly used languages for Object-Relational Database Management systems. It is mainly used for large web applications. It is an open-source, object-oriented, -relational database system. It is extremely powerful and enables users to extend any system without problem. It extends and uses the SQL language in combination with various features for safely scaling and storage of intricate data workloads.

List different datatypes of PostgreSQL?

Listed below are some of the new data types in PostgreSQL

  • UUID
  • Numeric types
  • Boolean
  • Character types
  • Temporal types
  • Geometric primitives
  • Arbitrary precision numeric
  • XML
  • Arrays etc

What are the Indices of PostgreSQL?

Indices in PostgreSQL allow the database server to find and retrieve specific rows in a given structure. Examples are B-tree, hash, GiST, SP-GiST, GIN and BRIN. Users can also define their indices in PostgreSQL. However, indices add overhead to the data manipulation operations and are seldom used

What are tokens in PostgreSQL?

Tokens in PostgreSQL act as the building blocks of a source code. They are composed of various special character symbols. Commands are composed of a series of tokens and terminated by a semicolon(“;”). These can be a constant, quoted identifier, other identifiers, keyword or a constant. Tokens are usually separated by whitespaces.

How to create a database in PostgreSQL?

Databases can be created using 2 methods

  • First is the CREATE DATABASE SQL Command

We can create the database by using the syntax:-

DELETE FROM employee
WHERE [age=25];

5

  • The second is by using the createdb command

We can create the database by using the syntax:-

DELETE FROM employee
WHERE [age=25];

6

Various options can be taken by the createDB command based on the use case.

How to create a table in PostgreSQL?

You can create a new table by specifying the table name, along with all column names and their types:

DELETE FROM employee
WHERE [age=25];

7

How can we change the column datatype in PostgreSQL?

The column the data type can be changed in PostgreSQL by using the ALTER TABLE command:

DELETE FROM employee
WHERE [age=25];

8

Compare ‘PostgreSQL’ with ‘MongoDB’

PostgreSQLMongoDBPostgreSQL is an SQL database where data is stored as tables, with structured rows and columns. It supports concepts like referential integrity entity-relationship and JOINS. PostgreSQL uses SQL as its querying language. PostgreSQL supports vertical scaling. This means that you need to use big servers to store data. This leads to a requirement of downtime to upgrade. It works better if you require relational databases in your application or need to run complex queries that test the limit of SQL.MongoDB, on the other hand, is a NoSQL database. There is no requirement for a schema, therefore it can store unstructured data. Data is stored as BSON documents and the document’s structure can be changed by the user. MongoDB uses JavaScript for querying. It supports horizontal scaling, as a result of which additional servers can be added as per the requirement with minimal to no downtime. It is appropriate in a use case that requires a highly scalable distributed database that stores unstructured data

What is Multi-Version concurrency control in PostgreSQL?

MVCC or better known as Multi-version concurrency control is used to implement transactions in PostgreSQL. It is used to avoid unwanted locking of a database in the system. while querying a database each transaction sees a version of the database. This avoids viewing inconsistencies in the data, and also provides transaction isolation for every database session. MVCC locks for reading data do not conflict with locks acquired for

How do you delete the database in PostgreSQL?

Databases can be deleted in PostgreSQL using the syntax

DELETE FROM employee
WHERE [age=25];

9

Please note that only databases having no active connections can be dropped.

What does a schema contain?

  • Schemas are a part of the database that contains tables. They also contain other kinds of named objects, like data types, functions, and operators.
  • The object names can be used in different schemas without conflict; Unlike databases, schemas are separated more flexibly. This means that a user can access objects in any of the schemas in the database they are connected to, till they have privileges to do so.
  • Schemas are highly beneficial when there is a need to allow many users access to one database without interfering with each other. It helps in organizing database objects into logical groups for better manageability. Third-party applications can be put into separate schemas to avoid conflicts based on names.

What is the square root operator in PostgreSQL?

It is denoted by ‘|/” and returns the square root of a number. Its syntax is

Egs:- Select |/16

How are the stats updated in Postgresql?

To update statistics in PostgreSQL a special function called an explicit ‘vacuum’ call is made. Entries in pg_statistic are updated by the ANALYZE and VACUUM ANALYZE commands

What Is A Candid?

The CTIDs field exists in every PostgreSQL table. It is unique for every record of a table and exactly shows the location of a tuple in a particular table. A logical row’s CTID changes when it is updated, thus it cannot be used as a permanent row identifier. However, it is useful when identifying a row within a transaction when no update is expected on the data item.

What is Cube Root Operator (||/) in PostgreSQL?

It is denoted by ‘|/” and returns the square root of a number. Its syntax is

Egs:- Select |/16

Explain Write-Ahead Logging?

Write-ahead logging is a method to ensure data integrity. It is a protocol that ensures writing the actions as well as changes into a transaction log. It is known to increase the reliability of databases by logging changes before they are applied or updated onto the database. This provides a backup log for the database in case of a crash.

What is a non-clustered index?

A non-clustered index in PostgreSQL is a simple index, used for fast retrieval of data, with no certainty of the uniqueness of data. It also contains pointers to locations where other parts of data are stored

How is security ensured in PostgreSQL?

PostgreSQL uses 2 levels of security

  • Network-level security uses Unix Domain sockets, TCP/IP sockets, and firewalls.
  • Transport-level security which uses SSL/TLS to enable secure communication with the database
  • Database-level security with features like roles and permissions, row-level security (RLS), and auditing.

SQL Practice Questions

PART 1

This covers SQL basic query operations like creating databases forms scratch, creating a table, inserting values etc.

It is better to get hands-on in order to have practical experience with SQL queries. A small error/bug will make you feel surprised and next time you will get there!

Let’s get started!

  1. Create a Database bank

CREATE DATABASE databasename.

0

  1. Create a table with the name “bank_details” with the following columns

— Product with string data type

— Quantity with numerical data type

— Price with real number data type

— purchase_cost with decimal data type

— estimated_sale_price with data type float

CREATE DATABASE databasename.

1

  1. Display all columns and their datatype and size in Bank_details
  1. Insert two records into Bank_details.

— 1st record with values —

— Product: PayCard

— Quantity: 3

— price: 330

— Puchase_cost: 8008

— estimated_sale_price: 9009

— Product: PayPoints —

— Quantity: 4

— price: 200

— Puchase_cost: 8000

— estimated_sale_price: 6800

CREATE DATABASE databasename.

2

  1. Add a column: Geo_Location to the existing Bank_details table with data type varchar and size 20

CREATE DATABASE databasename.

3

  1. What is the value of Geo_location for a product : “PayCard”?

CREATE DATABASE databasename.

4

  1. How many characters does the Product : “paycard” have in the Bank_details table.

CREATE DATABASE databasename.

5

  1. Alter the Product field from CHAR to VARCHAR in Bank_details

CREATE DATABASE databasename.

6

  1. Reduce the size of the Product field from 10 to 6 and check if it is possible

CREATE DATABASE databasename.

7

  1. Create a table named as Bank_Holidays with below fields

— a) Holiday field which displays only date

— b) Start_time field which displays hours and minutes

— c) End_time field which also displays hours and minutes and timezone

CREATE DATABASE databasename.

8

  1. Step 1: Insert today’s date details in all fields of Bank_Holidays

— Step 2: After step1, perform the below

— Postpone Holiday to next day by updating the Holiday field

CREATE DATABASE databasename.

9

Update the End_time with current European time.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

00

  1. Display output of PRODUCT field as NEW_PRODUCT in Bank_details table

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

01

  1. Display only one record from bank_details

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

02

  1. Display the first five characters of the Geo_location field of Bank_details.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

03

PART 2

— ——————————————————–

# Datasets Used: cricket_1.csv, cricket_2.csv

— cricket_1 is the table for cricket test match 1.

— cricket_2 is the table for cricket test match 2.

— ——————————————————–

Find all the players who were present in the test match 1 as well as in the test match 2.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

04

Write a MySQl query to find the players from the test match 1 having popularity higher than the average popularity.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

05

Find player_id and player name that are common in the test match 1 and test match 2.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

06

Retrieve player_id, runs, and player_name from cricket_1 and cricket_2 table and display the player_id of the players where the runs are more than the average runs.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

07

Write a query to extract the player_id, runs and player_name from the table “cricket_1” where the runs are greater than 50.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

08

Write a query to extract all the columns from cricket_1 where player_name starts with ‘y’ and ends with ‘v’.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

09

Write a query to extract all the columns from cricket_1 where player_name does not end with ‘t’.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

10

# Dataset Used: cric_combined.csv

Write a MySQL query to create a new column PC_Ratio that contains the popularity to charisma ratio.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

11

Write a MySQL query to find the top 5 players having the highest popularity to charisma ratio

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

12

Write a MySQL query to find the player_ID and the name of the player that contains the character “D” in it.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

13

Dataset Used: new_cricket.csv

Extract the Player_Id and Player_name of the players where the charisma value is null.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

14

Write a MySQL query to impute all the NULL values with 0.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

15

Separate all Player_Id into single numeric ids (example PL1 = 1).

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

16

Write a MySQL query to extract Player_Id, Player_Name and charisma where the charisma is greater than 25.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

17

# Dataset Used: churn1.csv

Write a query to count all the duplicate values from the column “Agreement” from the table churn1.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

18

Rename the table churn1 to “Churn_Details”.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

19

Write a query to create a new column new_Amount that contains the sum of TotalAmount and MonthlyServiceCharges.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

20

Rename column new_Amount to Amount.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

21

Drop the column “Amount” from the table “Churn_Details”.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

22

Write a query to extract the customerID, InternetConnection and gender from the table “Churn_Details ” where the value of the column “InternetConnection” has ‘i’ at the second position.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

23

Find the records where the tenure is 6x, where x is any number.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

24

Part 3

# DataBase = Property Price Train

Dataset used: Property_Price_Train_new

Write An MySQL Query To Print The First Three Characters Of Exterior1st From Property_Price_Train_new Table.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

25

Write An MySQL Query To Print Brick_Veneer_Area Of Property_Price_Train_new Excluding Brick_Veneer_Type, “None” And “BrkCmn” From Property_Price_Train_new Table.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

26

Write An MySQL Query to print Remodel_Year , Exterior2nd of the Property_Price_Train_new Whose Exterior2nd Contains ‘H’.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

27

Write MySQL query to print details of the table Property_Price_Train_new whose Remodel_year from 1983 to 2006

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

28

Write MySQL query to print details of Property_Price_Train_new whose Brick_Veneer_Type ends with e and contains 4 alphabets.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

29

Write MySQl query to print nearest largest integer value of column Garage_Area from Property_Price_Train_new

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

30

Fetch the 3 highest value of column Brick_Veneer_Area from Property_Price_Train_new table

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

31

Rename column LowQualFinSF to Low_Qual_Fin_SF fom table Property_Price_Train_new

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

32

Convert Underground_Full_Bathroom (1 and 0) values to true or false respectively.

# Eg. 1 – true ; 0 – false

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

33

Extract total Sale_Price for each year_sold column of Property_Price_Train_new table.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

34

Extract all negative values from W_Deck_Area

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

35

Write MySQL query to extract Year_Sold, Sale_Price whose price is greater than 100000.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

36

Write MySQL query to extract Sale_Price and House_Condition from Property_Price_Train_new and Property_price_train_2 perform inner join. Rename the table as PPTN and PPTN2.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

37

Count all duplicate values of column Brick_Veneer_Type from tbale Property_Price_Train_new

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

38

# DATABASE Cricket

Find all the players from both matches.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

04

Perform right join on cricket_1 and cricket_2.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

40

Perform left join on cricket_1 and cricket_2

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

41

Perform left join on cricket_1 and cricket_2.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

42

Create a new table and insert the result obtained after performing inner join on the two tables cricket_1 and cricket_2.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

43

Write MySQL query to extract maximum runs of players get only top two players

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

44

PART 4

# Pre-Requisites

# Assuming Candidates are familiar with “Group by” and “Grouping functions” because these are used along with JOINS in the questionnaire.

# Create below DB objects

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

45

Print customer Id, customer name and average account_balance maintained by each customer for all of his/her accounts in the bank.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

46

Print customer_id , account_number and balance_amount ,

condition that if balance_amount is nil then assign transaction_amount for account_type = “Credit Card”

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

47

Print customer_id , account_number and balance_amount ,

# conPrint account number, balance_amount, transaction_amount from Bank_Account_Details and bank_account_transaction

# for all the transactions occurred during march,2020 and april, 2020

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

48

Print all of the customer id, account number, balance_amount, transaction_amount from bank_customer,

# Bank_Account_Details and bank_account_transaction tables where excluding all of their transactions in march, 2020 month

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

49

Print only the customer id, customer name, account_number, balance_amount who did transactions during the first quarter.

# Do not display the accounts if they have not done any transactions in the first quarter.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

50

Print account_number, Event adn Customer_message from BANK_CUSTOMER_MESSAGES and Bank_Account_Details to display an “Adhoc”

# Event for all customers who have “SAVINGS” account_type account.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

51

Print Customer_id, Account_Number, Account_type, and display deducted balance_amount by

# subtracting only negative transaction_amounts for Relationship_type = “P” ( P – means Primary , S – means Secondary )

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

52

Display records of All Accounts, their Account_types, the transaction amount.

# b) Along with the first step, Display other columns with the corresponding linking account number, account types

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

53

Display records of All Accounts, their Account_types, the transaction amount.

# b) Along with the first step, Display other columns with corresponding linking account number, account types

# c) After retrieving all records of accounts and their linked accounts, display the transaction amount of accounts appeared in another column.

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

54

Display all saving account holders have “Add-on Credit Cards” and “Credit cards”

 CREATE TABLE table_name (
  column1 datatype,
  column2 datatype,
  column3 datatype,
   ....
);

55

That covers the most asked or SQL practiced questions.

Frequently Asked Questions in SQL

1. How do I prepare for the SQL interview?

Many online sources can help you prepare for an SQL interview. You can go through brief tutorials and free online courses on SQL (eg.: SQL basics on Great Learning Academy) to revise your knowledge of SQL. You can also practice projects to help you with practical aspects of the language. Lastly, many blogs such as this list all the probable questions that an interviewer might ask.

2. What are the 5 basic SQL commands?

The five basic SQL commands are:

  • Data Definition Language (DDL)
  • Data Manipulation Language (DML)
  • Data Control Language (DCL)
  • Transaction Control Language (TCL)
  • Data Query Language (DQL)

3. What are basic SQL skills?

SQL is a vast topic and there is a lot to learn. But the most basic skills that an SQL professional should know are:

  • How to structure a database
  • Managing a database
  • Authoring SQL statements and clauses
  • Knowledge of popular database systems such as MySQL
  • Working knowledge of PHP
  • SQL data analysis
  • Creating a database with WAMP and SQL

4. How can I practice SQL?

There are some platforms available online that can help you practice SQL such as SQL Fiddle, SQLZOO, W3resource, Oracle LiveSQL, DB-Fiddle, Coding Groud, GitHub and others. Also take up a Oracle SQL to learn more.

5. Where can I practice SQL questions?

There are some platforms available online that can help you practice SQL such as SQL Fiddle, SQLZOO, W3resource, Oracle LiveSQL, DB-Fiddle, Coding Groud, GitHub and others.

You can also refer to articles and blogs online that list the most important SQL interview questions for preparation.

6. What is the most common SQL command?

Some of the most common SQL commands are:

  • CREATE DATABASE
  • ALTER DATABASE
  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
  • CREATE INDEX
  • DROP INDEX

7. How are SQL commands classified?

SQL Commands are classified under four categories, i.e.,

  • Data Definition Language (DDL)
  • Data Query Language (DQL)
  • Data Manipulation Language (DML)
  • Data Control Language (DCL)

8. What are basic SQL commands?

Basic SQL commands are:

  • CREATE DATABASE
  • ALTER DATABASE
  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
  • CREATE INDEX
  • DROP INDEX

9. Is SQL coding?

Yes, SQL is a coding language/ programming language that falls under the category of domain-specific programming language. It is used to access relational databases such as MySQL.

10. What is SQL example?

SQL helps you update, delete, and request information from databases. Some of the examples of SQL are in the form of the following statements:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE DATABASE
  • ALTER DATABASE

11. What is SQL code used for?

SQL code is used to access and communicate with a database. It helps in performing tasks such as updating and retrieving data from the databases.

To Conclude

For anyone who is well-versed in SQL knows that it is the most widely used Database language. Thus, the most essential part to learn is SQL for Data Science to power ahead in your career.

Wondering where to learn the highly coveted in-demand skills for free? Check out the courses on Great Learning Academy. Enroll in any course, learn the in-demand skill, and get your free certificate. Hurry!

What were the top 3 challenges you face in SQL?

Let's look at the main obstacles that make learning SQL so difficult..

SQL dialects and syntax: Learning SQL dialects & syntax is cumbersome..

Interoperability of versions: Need to learn and adapt to each version..

Query speed and efficiency..

Understanding table structure and table relationships in SQL is hard..

How do you talk about SQL experience in an interview?

When answering this question, you want to talk about the previous roles you've held where you've had experience using SQL. Be sure to include any programmes or software you know how to use and if you've undertaken any training courses or gained any qualifications.

How to crack SQL Interview Questions?

7 Tips to Crack SQL Interview Questions.

Ask Questions. ... .

Identify the Relevant Columns. ... .

Think About What Your Final Answer Should Look Like. ... .

Solve the Query One Step at a Time. ... .

Include Comments. ... .

Use Formatting. ... .

Talk Through the Process..

How to prepare for an SQL interview?

If you want to perform well at the SQL job interview, these are the concepts you need to know:.

Data Definition Language (DDL) keywords..

Data Manipulation Language (DML) keywords..

Data Control Language (DCL) keywords..

Transaction Control Language (TCL) keywords..

SQL constraints..

JOINs..

indexes..

transactions..