"Ace Your Data Analyst Interview: SQL
Questions You Can't Afford to Miss!
(PART I)🎯"
Basic SQL Knowledge:
1. What is SQL, and what does it stand for?
Answer: SQL is a standard language used to
ns
tio
interact with and manage data in relational
es
databases. It allows users to perform tasks such as
Qu
querying, inserting, updating, and deleting data.
e w
i Retrieval:
v
Data
r
t e
In
2. How do you retrieve all columns from a table
in SQL?
Answer: The 'SELECT *' statement retrieves all
columns from the specified table.
Use the 'SELECT * FROM table_name';
statement.
3. How can you select specific columns from a
table?
Answer: To select specific columns, list their
names after the 'SELECT' keyword, separated by
commas.
Use the 'SELECT column1, column2 FROM
table_name'; statement.
4. How do you add a condition to your SQL query
ns
o
using the WHERE clause?
t i
e sfilters the rows
u
Answer: The WHERE clause
returned by a query Q
iew based on a specific
r vcondition.
te
InWHERE clause with the desired
Use the
condition in the SELECT statement.
5. What is the difference between the WHERE
and HAVING clauses?
Answer: The WHERE clause filters rows before
data is grouped, whereas the HAVING clause
filters grouped data based on specified
conditions.
Data Filtering and Joins:
6. Explain the various types of SQL joins (INNER
JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN).
Answer: Joins are used to combine data from
multiple tables.
INNER JOIN: Returns only the matching rows
from both tables.
LEFT JOIN: Returns all rows from
ns the left
table and matching rows from tiothe right table.
e s
RIGHT JOIN: Returns all u rows from the right
Q from the left table.
table and matching
ew rows
i all rows when there is a
rv
FULL JOIN: Returns
e
ntin either the left or right table.
match
I
7. How do you combine multiple conditions in a
query using logical operators (AND, OR, NOT)?
Answer: Logical operators allow you to
combine conditions in a query. Use AND to
require all conditions to be true, OR to require
at least one condition to be true, and NOT to
negate a condition.
8. How do you use the LIKE operator for pattern
matching?
Answer: The LIKE operator is used for pattern
matching in SQL. '%' represents any number of
characters, while '_ 'represents a single
character.
The LIKE operator is used with the % wildcard
for pattern matching.
s
9. Explain the use of the GROUP BYnclause and
t io
s COUNT, AVG).
aggregate functions (e.g., SUM,
e
Q u
Answer: The 'GROUP' BY
ie w clause divides rows into
rv
groups based on the values of a specified column.
te
In
Aggregate functions then perform calculations on
each group, such as 'SUM', 'COUNT', and 'AVG'.
10. How can you filter the results of a GROUP BY
query using the HAVING clause?
Answer: The 'HAVING' clause filters the grouped
data based on specified conditions. It works
similarly to the 'WHERE' clause but operates on
the aggregated data.