0% found this document useful (0 votes)
17 views37 pages

SQL Interview Practice Guide

The document serves as a comprehensive guide to mastering SQL for technical interviews, covering fundamental concepts, data manipulation, and data analysis techniques. It emphasizes the importance of core SQL commands like SELECT, FROM, and WHERE, as well as advanced topics such as aggregate functions, GROUP BY, and the distinction between WHERE and HAVING clauses. The guide also discusses best practices and common interview questions to help candidates demonstrate their SQL proficiency.

Uploaded by

Vaibhav Bhosale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views37 pages

SQL Interview Practice Guide

The document serves as a comprehensive guide to mastering SQL for technical interviews, covering fundamental concepts, data manipulation, and data analysis techniques. It emphasizes the importance of core SQL commands like SELECT, FROM, and WHERE, as well as advanced topics such as aggregate functions, GROUP BY, and the distinction between WHERE and HAVING clauses. The guide also discusses best practices and common interview questions to help candidates demonstrate their SQL proficiency.

Uploaded by

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

The Definitive Guide to Mastering SQL for Technical

Interviews and Assessments

Part I: The Bedrock - SQL Fundamentals

This part establishes the non-negotiable foundation of Structured Query Language


(SQL). A candidate who stumbles on these core concepts signals a lack of
fundamental understanding. The focus here is on clarity, proper syntax, and the logic
behind each command. SQL is the standard language for interacting with relational
databases, allowing for the creation, deletion, updating, and retrieval of data.1 While
there are various dialects like MySQL, PostgreSQL, and SQL Server, their core syntax
is largely consistent.2

Section 1: First Queries - SELECT, FROM, and WHERE

The journey into SQL begins with retrieving data. The most fundamental statement for
this task is composed of three clauses: SELECT, FROM, and WHERE.

Core Concepts: SELECT and FROM

At its heart, every data retrieval query must answer two questions: what data do you
want, and where is it located? The SELECT and FROM clauses provide these answers.
●​ SELECT: This clause specifies the columns (or fields) you wish to retrieve from
the database. You can list one or more column names, separated by commas.4
●​ FROM: This clause specifies the table from which you are retrieving the data.4
These two clauses are the mandatory ingredients of any data retrieval query, and they
must appear in this specific order: SELECT followed by FROM.4

A simple query to retrieve the names and ages of all customers would look like this:

SQL

SELECTname, age​
FROM Customers;​

To select every column in a table without listing them individually, you can use the
asterisk (*) wildcard.4

SQL

SELECT *​
FROM Customers;​

While convenient for exploration, using SELECT * in production code or final interview
answers is generally discouraged. It can be inefficient as it may retrieve more data
than necessary and can make queries less readable and more prone to breaking if the
underlying table structure changes. Explicitly naming the required columns is best
practice.5

Filtering with WHERE

Rarely do you need every single row from a table. The WHERE clause is the primary
tool for filtering rows based on specific conditions, ensuring you only retrieve the data
that meets your criteria.1 It is applied to individual rows before any grouping or
aggregation occurs.7
The WHERE clause supports a wide array of operators to build precise conditions:
●​ Comparison Operators: These are used for comparing values. They include =, !=
or <> (not equal to), > (greater than), < (less than), >= (greater than or equal to),
and <= (less than or equal to).9
○​ Example: Retrieve products with a price greater than 50.00.​
SQL​
SELECTproduct_name, price​
FROM Products​
WHERE price > 50.00;​

●​ Logical Operators: AND, OR, and NOT are used to combine multiple conditions.1
○​ AND: All conditions must be true.
○​ OR: At least one of the conditions must be true.
○​ NOT: Reverses the result of a condition.
○​ Example: Retrieve American cities with a population over 100,000.​
SQL​
SELECT *​
FROM CITY​
WHERE COUNTRYCODE = 'USA' AND POPULATION > 100000; -- [10]​

●​ Range and List Operators:


○​ BETWEEN: Selects values within a given range (inclusive).
○​ IN: Specifies a list of possible values for a column. This is often a more concise
and readable alternative to multiple OR conditions.6
○​ Example: Retrieve employees from the 'Sales' or 'Marketing' departments.​
SQL​
SELECTemployee_name, department​
FROM Employees​
WHERE department IN ('Sales', 'Marketing');​

●​ Pattern Matching with LIKE: This operator is used for searching for a specified
pattern in a column. It is particularly useful for string data and employs two
wildcards 12:
○​ %: Represents zero, one, or multiple characters.
○​ _: Represents a single character.
○​ Example: Find all users whose email address is from 'example.com'.​
SQL​
SELECTfirst_name, last_name, email​
FROM users​
WHERE email LIKE '%@example.com'; -- [13]​

○​ Example: Find a name where 'a' is the second letter.​


SQL​
SELECTname​
FROM names_table​
WHERE name LIKE '_a%'; -- [14]​

Handling the Void - NULL Values

In SQL, a NULL value represents missing or unknown data. It is fundamentally different


from a zero or a blank space.3 Because

NULL is not a specific value, it cannot be compared using standard comparison


operators like = or !=. Instead, you must use IS NULL or IS NOT NULL.
●​ IS NULL: Finds rows where a column's value is NULL.
●​ IS NOT NULL: Finds rows where a column has a value.

Example: Find customers who do not have a referee.

SQL

SELECTname​
FROM Customer​
WHERE referee_id IS NULL; -- [15]​

This is a common stumbling block for beginners and a frequent topic in interview
questions. Using WHERE referee_id = NULL will not return the expected results.

The WHERE clause functions as the first critical gatekeeper in the query execution
process. The database engine first identifies the table in the FROM clause and then
evaluates each row against the conditions specified in the WHERE clause. Only the
rows that satisfy these conditions are passed on to the subsequent stages of the
query, such as grouping, aggregation, or ordering.7 This row-by-row filtering
mechanism is precisely why aggregate functions like

SUM() or COUNT() cannot be used in the WHERE clause; at this stage, the data has
not yet been grouped to perform such calculations. This principle is a cornerstone for
understanding the difference between WHERE and the HAVING clause, which will be
discussed later.

Section 2: Shaping Your Results - ORDER BY, DISTINCT, and Aliases

Once you have selected and filtered your data, the next step is to present it in a clear
and meaningful way. The ORDER BY, DISTINCT, and alias (AS) clauses are essential for
this purpose.

Sorting with ORDER BY

The ORDER BY clause is used to sort the result set in ascending or descending order
based on one or more columns.16
●​ ASC: Sorts in ascending order (A-Z, 0-9). This is the default behavior if no order is
specified.16
●​ DESC: Sorts in descending order (Z-A, 9-0).

You can sort by multiple columns. The query will sort by the first column specified,
and then for any rows with the same value in the first column, it will sort them by the
second column, and so on.

Example: Show sales ordered by the most recent date first, and then alphabetically
by salesperson for sales on the same date.

SQL

SELECT *​
FROM SALES​
ORDER BY SaleDate DESC, Salesperson ASC; -- [16]​

Removing Duplicates with DISTINCT

The DISTINCT keyword is used within the SELECT clause to return only unique
(different) values from a column or a combination of columns.3

Example: Get a list of unique cities from the STATION table that have an even ID
number.

SQL

SELECT DISTINCT CITY​


FROM STATION​
WHERE MOD(id, 2) = 0; -- [10]​

In this query, if the city 'New York' appears multiple times for different even-ID
stations, it will only be listed once in the final result.

The Power of AS - Aliases

Aliases provide a temporary, more readable name for columns or tables within a
query. They are defined using the AS keyword (though in many SQL dialects, AS is
optional).1 Using aliases is not merely a convenience; it is a hallmark of clean,
professional, and maintainable code—a quality highly valued in any technical role.18
●​ Column Aliases: Used to make output headers more descriptive, especially for
calculated columns.
○​ Example:​
SQL​
SELECT AVG(price) AS average_price​
FROM Products;​
●​ Table Aliases: Used to shorten table names in complex queries, especially those
involving JOINs, making the query easier to write and read.
○​ Example:​
SQL​
SELECT c.first_name, o.order_id​
FROM Customers AS c​
JOIN Orders AS o ON c.customer_id = o.customer_id; -- [17]​

A subtle but important point that distinguishes proficient SQL users is understanding
the order of query execution. The logical processing order is generally: FROM ->
WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY.19 Because the

SELECT clause (where column aliases are defined) is processed before the ORDER BY
clause, you can use a column alias in your ORDER BY statement.

Example:

SQL

SELECTproduct_line, SUM(total) AS total_gain​


FROM sales​
GROUP BY product_line​
ORDER BY total_gain DESC; -- [19]​

Here, total_gain is a valid reference in the ORDER BY clause. However, you could not
use this alias in the WHERE or HAVING clause, as they are processed before the
SELECT statement. This understanding demonstrates a deeper grasp of SQL
mechanics beyond simple syntax memorization.

Section 3: Data Manipulation and Definition (DML & DDL)

While the majority of interview questions focus on data retrieval (SELECT queries,
which belong to the Data Query Language or DQL), a well-rounded data professional
must also be familiar with commands that define and manipulate the database
structure and its data.1 These commands are categorized into Data Definition
Language (DDL) and Data Manipulation Language (DML).

DML Commands

DML commands are used to manage data within existing table objects.1
●​ INSERT INTO: Adds new rows of data to a table. You can insert a single row or
multiple rows at once.1
●​ UPDATE: Modifies existing records in a table.1
●​ DELETE: Removes existing rows from a table.1

Example: Increase the salary by 10% for all employees in the "Sales" department.

SQL

UPDATE employees​
SET salary = salary * 1.10​
WHERE department = 'Sales'; -- [13]​

DDL Commands

DDL commands are used to define, modify, and remove database objects themselves,
such as tables.1
●​ CREATE TABLE: Creates a new table in the database.1
●​ ALTER TABLE: Modifies the structure of an existing table (e.g., adding or dropping
a column).1
●​ DROP TABLE: Permanently removes an entire table, including its structure and all
data.1
●​ TRUNCATE TABLE: Removes all rows from a table quickly, but keeps the table
structure intact.1

Key Interview Question: DELETE vs. TRUNCATE vs. DROP

This is a classic interview question that separates candidates who know syntax from
those who understand database mechanics. The question is a proxy for assessing a
candidate's understanding of deeper concepts like transactional control, logging, and
performance.

Command Type Operation Rollback? Triggers? Speed

DELETE DML Removes Yes Fires DELETE Slowest (for


rows one by triggers for large tables)
one based each row.
on a WHERE
clause (or all
rows if no
WHERE).

TRUNCATE DDL Deallocates No (or Does not fire Fastest


data pages, limited, DELETE
removing all dialect-depe triggers.
rows at ndent)
once.

DROP DDL Permanently No No Fast


removes the table-level
entire table triggers
object exist.
(structure
and data).

A strong answer moves beyond these basic definitions. It demonstrates an awareness


of the underlying database engine's behavior and the trade-offs involved.3 For
example, a candidate might explain that

DELETE is a fully logged operation for each row removed. This makes it recoverable
within a transaction but potentially very slow and resource-intensive for large tables.
In contrast, TRUNCATE is minimally logged (it only logs the deallocation of the data
pages), which makes it extremely fast but also much harder, if not impossible, to roll
back. This shows an understanding of the transaction log, a critical component of any
relational database, and the crucial trade-off between safety (DELETE) and
performance (TRUNCATE). This level of analysis signals that the candidate thinks
about the real-world consequences of their commands, a vital skill for anyone working
with production data systems.

Part II: Analyzing and Aggregating Data

This section delves into the core of data analysis with SQL. The ability to summarize,
group, and filter aggregated data is a non-negotiable skill for any data analyst,
scientist, or business intelligence professional. Mastery of these concepts is essential
for transforming raw data into meaningful insights.

Section 4: Summarizing Data - Aggregate Functions

Aggregate functions perform a calculation on a set of values and return a single,


summary value.1 They are the building blocks of most analytical queries.

The most common aggregate functions are:


●​ COUNT(): Counts the number of rows.
●​ SUM(): Calculates the sum of a set of numeric values.
●​ AVG(): Calculates the average of a set of numeric values.
●​ MIN(): Returns the minimum value in a set.
●​ MAX(): Returns the maximum value in a set.

Example: Find the difference between the maximum and minimum populations in the
CITY table.

SQL
SELECT MAX(POPULATION) - MIN(POPULATION)​
FROM CITY; -- [20]​

The Nuance of COUNT()

A frequent point of confusion, and thus a common interview topic, is the subtle
difference in how COUNT() behaves depending on its argument. Precision here
demonstrates a solid understanding.
●​ COUNT(*): Counts the total number of rows in the result set, including rows with
NULL values. It is generally the most performant way to get a total row count.8
●​ COUNT(column_name): Counts the number of rows where column_name is not
NULL. It ignores any rows where the specified column has a NULL value.
●​ COUNT(DISTINCT column_name): Counts the number of unique, non-NULL
values in column_name.

Example: Find the difference between the total number of city entries and the
number of distinct city entries. This tells you how many city names are duplicated in
the table.

SQL

SELECT COUNT(CITY) - COUNT(DISTINCT CITY)​


FROM station; -- [10]​

Section 5: Grouping and Filtering Aggregates - GROUP BY and HAVING

Aggregate functions are most powerful when combined with the GROUP BY clause,
which allows you to perform calculations on subsets of your data.
Grouping with GROUP BY

The GROUP BY statement groups rows that have the same values in specified columns
into summary rows.8 It is used with aggregate functions to perform calculations on
each group. For instance, you can calculate the total sales

per product category or the number of orders per customer.8

You can group by a single column or multiple columns. When grouping by multiple
columns, a unique group is formed for each distinct combination of values in those
columns.21

Example: Calculate the total sales for each product category.

SQL

SELECTproduct_category, SUM(sales_amount) AS total_sales​


FROM sales​
GROUP BY product_category; -- [8]​

Example: Count the number of students for each subject and year.

SQL

SELECTSUBJECT, YEAR, COUNT(*)​


FROM Student​
GROUP BY SUBJECT, YEAR; -- [21]​

Filtering Groups with HAVING

After grouping your data, you might want to filter the groups themselves. For example,
you might want to see only the departments where the average salary exceeds
$50,000. This is where the HAVING clause comes in. It is specifically designed to filter
groups based on the results of aggregate functions.22

Example: Find product categories with total sales exceeding $10,000.

SQL

SELECT product_category, SUM(sales_amount) AS total_sales​


FROM sales​
GROUP BY product_category​
HAVING SUM(sales_amount) > 10000; -- [8]​

The Critical Distinction: WHERE vs. HAVING

One of the most classic and revealing SQL interview questions is to explain the
difference between the WHERE and HAVING clauses. A clear answer demonstrates a
fundamental understanding of how SQL processes queries.

Clause Purpose When it Operates Works with


Aggregates?

WHERE Filters individual Before grouping. No


rows.

HAVING Filters entire groups After grouping. Yes


of rows.

●​ WHERE filters rows before they are grouped. It operates on the raw data from
the tables.7
●​ HAVING filters groups after they have been created by GROUP BY. It
operates on the summarized result set.7

This operational difference is why you cannot use an aggregate function like SUM() in
a WHERE clause, but you must use one in a HAVING clause.19

Example: Find the total sales for each region, but only consider individual sales
greater than $500, and only show regions with total sales over $10,000.

SQL

SELECT region, SUM(sales_amount) AS total_sales​


FROM sales​
WHERE sales_amount > 500​
GROUP BY region​
HAVING SUM(sales_amount) > 10000; -- [8]​

Here, WHERE first filters out individual sales of $500 or less. Then, GROUP BY
calculates the total sales for the remaining transactions in each region. Finally,
HAVING filters out the regions where the calculated total is not over $10,000.

The SQL Order of Execution: A Mental Model for Debugging

The key to truly internalizing the WHERE vs. HAVING distinction—and to debugging
many other common SQL errors—is to understand the logical order in which the
database engine processes a query. While you write a query in a certain order
(SELECT, FROM, WHERE...), the database executes it in a different, logical order.19

The logical query processing order is:


1.​ FROM (and JOINs)
2.​ WHERE
3.​ GROUP BY
4.​ HAVING
5.​ SELECT
6.​ DISTINCT
7.​ ORDER BY
8.​ LIMIT / TOP
This sequence is not just a piece of trivia; it is a powerful mental model for writing and
debugging SQL.19 When a query fails, a strong candidate can mentally trace this
execution path to pinpoint the failure point. For instance, an "invalid column name"
error when using a

SELECT alias in a WHERE clause becomes instantly understandable: the WHERE


clause is processed long before the SELECT clause, so the alias simply does not exist
at that stage. This framework elevates a candidate from someone who "tries things
until they work" to a professional who writes correct code from the start because they
understand the process. This demonstrates a depth of thinking that interviewers
actively seek.

Part III: Combining and Structuring Complex Data

This section addresses the skills that separate proficient SQL users from beginners. In
any real-world database, data is strategically distributed across multiple tables to
ensure integrity and reduce redundancy—a concept known as normalization. The
ability to combine, structure, and analyze data from these disparate tables is
therefore paramount. Mastery of JOINs, subqueries, CTEs, and window functions is
essential for tackling complex analytical tasks.

Section 6: The Heart of Relational Databases - JOINs

JOIN clauses are the fundamental mechanism for combining rows from two or more
tables based on a related column between them.17 Without

JOINs, relational databases would be little more than a collection of disconnected


spreadsheets.

Types of JOINs
Understanding the different types of JOINs and when to use each is critical. The type
of join determines which rows from each table are included in the final result set.
●​ INNER JOIN: This is the most common type of join. It returns only the rows where
the join condition is met in both tables. If a row in one table does not have a
matching row in the other, it is excluded from the result.6
●​ LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table (the table
specified after FROM) and the matched rows from the right table (the table
specified after JOIN). If there is no match for a row from the left table, the
columns from the right table will contain NULL values.6 The​
OUTER keyword is optional and does not change the behavior; LEFT JOIN and
LEFT OUTER JOIN are identical.3
●​ RIGHT JOIN (or RIGHT OUTER JOIN): This is the inverse of a LEFT JOIN. It
returns all rows from the right table and the matched rows from the left table. If
there is no match, columns from the left table will be NULL.6
●​ FULL OUTER JOIN: This join combines the behavior of LEFT and RIGHT joins. It
returns all rows when there is a match in either the left or the right table. It
effectively returns all rows from both tables, filling in NULLs where matches do
not exist on either side.6
●​ CROSS JOIN: This join returns the Cartesian product of the two tables. Every row
from the first table is combined with every row from the second table. It is used
less frequently and typically does not have an ON clause.26
●​ SELF JOIN: This is not a distinct join type but a technique where a table is joined
to itself. It is essential for querying hierarchical data (e.g., finding an employee's
manager within the same Employees table) or for making comparisons between
rows within the same table.5 A table alias is required for a self join.

JOIN Type Comparison

Visualizing how each join type includes or excludes data is crucial for intuitive
understanding. The following table provides a clear, side-by-side comparison.

Assume we have two tables: Customers and Orders.

Customers Table

CustomerID Name
1 Alice

2 Bob

3 Charlie

Orders Table

OrderID CustomerID Amount

101 1 50

102 1 75

103 2 120

104 4 200

Join Type Venn Diagram Description Example Query Result Set

INNER JOIN Returns only SELECT c.Name, Alice, 50 Alice,


records that o.Amount FROM 75 Bob, 120
have matching Customers c
values in both INNER JOIN
tables. Orders o ON
c.CustomerID =
o.CustomerID;

LEFT JOIN Returns all SELECT c.Name, Alice, 50 Alice,


records from o.Amount FROM 75 Bob, 120
the left table Customers c Charlie, NULL
(Customers), LEFT JOIN
and the Orders o ON
matched c.CustomerID =
records from o.CustomerID;
the right table
(Orders).

RIGHT JOIN !(https://i.imgur.c Returns all SELECT c.Name, Alice, 50 Alice,


om/sSCTz1c.png records from o.Amount FROM 75 Bob, 120
) the right table Customers c NULL, 200
(Orders), and RIGHT JOIN
the matched Orders o ON
records from c.CustomerID =
the left table o.CustomerID;
(Customers).

FULL OUTER Returns all SELECT c.Name, Alice, 50 Alice,


JOIN records when o.Amount FROM 75 Bob, 120
there is a match Customers c Charlie, NULL
in either the left FULL OUTER NULL, 200
or right table. JOIN Orders o
ON
c.CustomerID =
o.CustomerID;

Section 7: Advanced Query Structuring - Subqueries and Common Table


Expressions (CTEs)

As queries become more complex, nesting logic within a single, monolithic block
becomes unreadable and difficult to maintain. Subqueries and Common Table
Expressions (CTEs) are two powerful constructs for structuring complex logic into
manageable, modular parts.

Subqueries (Inner Queries)

A subquery is a SELECT statement that is nested inside another SQL statement (the
outer query).1 The result of the inner query is used by the outer query.
●​ Types of Subqueries:
○​ Single-row subquery: Returns only one row. Can be used with standard
comparison operators (=, >, etc.).
○​ Multi-row subquery: Returns multiple rows. Must be used with operators like
IN, NOT IN, ANY, or ALL.11
○​ Correlated subquery: This is an advanced and powerful type where the inner
query depends on the outer query for its values. The subquery is re-evaluated
for each row processed by the outer query.11 While potent, correlated
subqueries can be slow and should be used with caution, as they can lead to
performance issues if not written carefully.28

Example: Find all employees whose salary is greater than the average salary in their
respective department (a correlated subquery).

SQL

SELECT employee_id, department_id, salary​


FROM employees e​
WHERE salary > (​
SELECT AVG(salary)​
FROM employees​
WHERE department_id = e.department_id​
); -- [13]​

Common Table Expressions (CTEs)

A Common Table Expression (CTE) is a temporary, named result set that you can
reference within a SELECT, INSERT, UPDATE, or DELETE statement. CTEs are defined
using the WITH clause and are often preferred over subqueries for their significant
improvements in readability and modularity.30

Syntax:

SQL

WITH cte_name AS (​
-- CTE query definition​
SELECT...​
)​
-- Main query that references the CTE​
SELECT * FROM cte_name; -- [11]​

Advantages of CTEs:
●​ Readability: They break down complex queries into logical, sequential steps,
making the query easier to read and understand.30
●​ Reusability: A CTE can be referenced multiple times within the main query,
avoiding the need to rewrite the same subquery repeatedly.30
●​ Recursion: CTEs can reference themselves, a feature known as recursion. This is
the standard and most effective way to query hierarchical data, such as
organizational charts or parts explosions.32

Example: Using a CTE to find supervisors.

SQL

WITH Supervisors AS (​
SELECT e.employee_id, e.employee_name, s.employee_name AS supervisor_name​
FROM employees e​
LEFT JOIN employees s ON e.supervisor_id = s.employee_id​
)​
SELECTemployee_id, employee_name, supervisor_name​
FROM Supervisors; -- [31]​

In an interview setting, using CTEs does more than just produce a correct answer; it
tells a story with the code. A well-structured query with clearly named CTEs acts as
self-documentation, guiding the interviewer through the logical steps of the solution.
A candidate can articulate their approach by saying, "First, I'll create a CTE named
MonthlyActiveUsers to isolate the users I need. Next, I'll create a second CTE called
UserFirstOrder to find each user's initial purchase date." This narrative approach
demonstrates structured thinking, strong communication skills, and an appreciation
for code maintainability—all qualities of a top-tier candidate. It elevates the
conversation from simply "Can you write this query?" to "Can you build a robust and
understandable solution?"
Section 8: The Analyst's Power Tool - Window Functions

Window functions are one of the most powerful features in modern SQL for advanced
analysis. They perform a calculation across a set of rows that are related to the
current row, but unlike aggregate functions with GROUP BY, they do not collapse the
rows into a single output row. Each row retains its separate identity.34

All window functions use the OVER() clause to define the "window" of rows the
function operates on. This clause has two key components:
●​ PARTITION BY: Divides the rows into partitions (groups). The window function is
applied independently to each partition. This is similar to GROUP BY but does not
collapse the rows.34
●​ ORDER BY: Orders the rows within each partition. This is crucial for functions that
depend on order, like ranking or running totals.34

Types of Window Functions

●​ Ranking Functions: These assign a rank to each row within a partition based on
the ORDER BY clause.
○​ ROW_NUMBER(): Assigns a unique, sequential integer to each row, starting
from 1. It gives distinct numbers even to rows with identical values (ties).34
○​ RANK(): Assigns a rank to each row. Rows with the same value in the ordering
column receive the same rank. However, RANK() leaves gaps in the sequence
after ties. For example, if two rows tie for rank 2, the next rank will be 4.28
○​ DENSE_RANK(): Similar to RANK(), but it does not leave gaps in the ranking
sequence after ties. If two rows tie for rank 2, the next rank will be 3.28
●​ Positional Functions: These access data from other rows relative to the current
row. They are invaluable for time-series analysis.
○​ LEAD(): Accesses data from a subsequent row (peeking forward).28
○​ LAG(): Accesses data from a preceding row (looking backward).28

Example: Calculate the difference in closing stock prices between consecutive


months.SQL​
SELECT​
date,​
close,​
LAG(close, 1) OVER (ORDER BY date) AS prev_month_close,​
close - LAG(close, 1) OVER (ORDER BY date) AS monthly_difference​
FROM stock_prices; -- [36]​

●​ Aggregate Functions as Window Functions: Standard aggregate functions like


SUM(), AVG(), and COUNT() can be used as window functions by adding an
OVER() clause. This is perfect for calculating running totals, moving averages, and
cumulative counts.33​
Example: Calculate a 7-day rolling average of daily active users.​
SQL​
SELECT​
date,​
active_users,​
AVG(active_users) OVER (ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT
ROW) AS rolling_7_day_avg​
FROM daily_active_users; -- [5]​

Window Ranking Function Comparison

The difference in how ranking functions handle ties is a frequent interview topic. The
following table clarifies this behavior.

Assume a sample table of player scores with ties:

Player Score

Amy 100

Bob 95

Carol 95

David 90

Emily 85

Frank 85
Grace 85

Henry 70

Query:

SQL

SELECT​
Player,​
Score,​
ROW_NUMBER() OVER (ORDER BY Score DESC) AS RowNum,​
RANK() OVER (ORDER BY Score DESC) AS Rank,​
DENSE_RANK() OVER (ORDER BY Score DESC) AS DenseRank​
FROM PlayerScores;​

Result:

Player Score RowNum Rank DenseRank Explanation

Amy 100 1 1 1

Bob 95 2 2 2 Bob and


Carol tie for
2nd place.

Carol 95 3 2 2 ROW_NUMB
ER continues
sequentially.
RANK and
DENSE_RAN
K give them
the same
rank.

David 90 4 4 3 RANK skips


rank 3
because of
the tie.
DENSE_RAN
K proceeds
to the next
rank, 3.

Emily 85 5 5 4 Three-way
tie for 5th
place.

Frank 85 6 5 4 ROW_NUMB
ER is unique.
RANK and
DENSE_RAN
K are the
same for all
three.

Grace 85 7 5 4

Henry 70 8 8 5 RANK skips


ranks 6 and
7.
DENSE_RAN
K proceeds
to the next
rank, 5.

Part IV: Essential Theory for the Modern Data Professional

Excelling in SQL interviews requires more than just writing correct queries. A top-tier
candidate demonstrates a deeper architectural awareness by understanding the
"why" behind the "what." This section covers essential database theory—indexing,
normalization, and ACID properties—that underpins the practical skills of query
writing. Discussing these topics intelligently signals maturity and a holistic
understanding of data systems.
Section 9: Performance and Optimization - Indexing

When a query on a small table runs slowly, it is an annoyance. When a query on a


table with millions or billions of rows runs slowly, it can bring a business to a halt.
Understanding query optimization is therefore a critical skill, and the most
fundamental concept in optimization is indexing.

What is an Index?

A database index is a data structure that improves the speed of data retrieval
operations on a table, at the cost of additional writes and storage space.37 The most
common analogy is the index at the back of a book. Instead of scanning every page to
find a topic (a "full table scan"), you can look up the topic in the index and go directly
to the correct page number.38 Similarly, a database index holds a sorted copy of one
or more columns with pointers to the corresponding data rows, allowing the database
to find records much more efficiently.39

The Indexing Trade-Off

The core principle to understand about indexing is its fundamental trade-off:


●​ Indexes speed up read operations (SELECT). This is especially true for queries
with WHERE, JOIN, or ORDER BY clauses on the indexed columns.37
●​ Indexes slow down write operations (INSERT, UPDATE, DELETE). When data
is modified, the database must update not only the table but also every index that
contains the modified column. This adds overhead.9

This trade-off means that indexing is not a universal solution. Over-indexing a table
that is frequently written to can harm performance more than it helps.37 The decision
to create an index requires a careful analysis of the table's query patterns.

Types of Indexes
●​ Clustered vs. Non-Clustered: This is a key distinction, particularly in interviews.
○​ A clustered index determines the physical order of data in a table. Because
the data itself is sorted according to the index key, a table can have only one
clustered index. The primary key of a table is often, by default, its clustered
index.37
○​ A non-clustered index is a separate data structure that contains the indexed
column values and a pointer to the location of the actual data row. The data
itself is not sorted according to this index. A table can have multiple
non-clustered indexes.9
●​ Single-column vs. Composite:
○​ A single-column index is created on a single column.
○​ A composite index (or multi-column index) is created on two or more
columns. This is useful for queries that frequently filter or join on a specific
combination of columns.37 The order of columns in a composite index matters
significantly.

In an interview, if you have written a query and the follow-up question is, "This query is
slow on a large table. How would you optimize it?", the first and best answer is almost
always related to indexing.5 A high-quality response would be: "My first step would be
to analyze the query's execution plan to see if the database is performing a full table
scan. If it is, I would recommend creating an index on the columns used in my

WHERE clause and in the ON conditions of my JOINs. This would allow the database
to perform a much faster index seek instead of reading every row in the table." This
answer is practical, precise, and demonstrates senior-level problem-solving skills.37

Section 10: Database Design Principles - Normalization

A common source of confusion for those new to SQL is why data is spread across so
many different tables. The answer lies in normalization, the process of organizing
tables in a database to minimize data redundancy and improve data integrity.27
Understanding normalization provides the foundational context for why

JOINs are not just a feature, but a necessity.

Normalization involves following a set of rules called "normal forms." While there are
several, 1NF, 2NF, and 3NF are the most important for practical purposes.44
●​ First Normal Form (1NF): A table is in 1NF if it meets two criteria:
1.​ Atomicity: Each cell must hold a single, indivisible value. You cannot have a
list of values in one cell.43
2.​ Primary Key: The table must have a primary key that uniquely identifies each
row.44
●​ Second Normal Form (2NF): A table is in 2NF if:
1.​ It is already in 1NF.
2.​ It has no partial dependencies. This means that every non-key attribute
must be fully dependent on the entire primary key. This rule is only relevant
for tables with a composite primary key (a primary key made of multiple
columns).44
●​ Third Normal Form (3NF): A table is in 3NF if:
1.​ It is already in 2NF.
2.​ It has no transitive dependencies. This means that a non-key attribute
cannot be dependent on another non-key attribute.44 For example, if you have​
EmployeeID -> DepartmentID -> DepartmentName, the dependency of
DepartmentName on DepartmentID is a transitive dependency that should be
resolved by moving DepartmentName to a separate Departments table.

The process of normalization explains why relational databases are designed the way
they are. To reduce data redundancy (e.g., storing a customer's full address with
every single order they place) and prevent data anomalies (e.g., having to update the
address in hundreds of places if they move), the data is broken apart into logically
distinct tables. The "cost" of this clean, non-redundant design is that you must use
JOINs to reassemble the information for analysis. A candidate who can articulate this
connection—"This schema appears to be in 3NF, which is why customer data is in a
separate table from their orders. To get a complete view, I'll need to JOIN them on
CustomerID"—demonstrates a holistic understanding of the data environment that
goes far beyond simple query writing.

Section 11: Ensuring Reliability - ACID Properties

For roles that are more backend-focused or involve database administration,


questions about ACID properties are common. ACID is an acronym that describes a
set of four properties that guarantee that database transactions are processed
reliably.27
●​ Atomicity: This property ensures that a transaction is an "all-or-nothing"
operation. It is treated as a single, indivisible unit of work. Either the entire
transaction completes successfully, or it fails completely, leaving the database in
its original state. This prevents partial updates that could lead to data
corruption.46
●​ Consistency: This ensures that a transaction can only bring the database from
one valid state to another. Any data written to the database must be valid
according to all defined rules, including constraints, cascades, and triggers. This
prevents transactions from violating the database's structural integrity.46
●​ Isolation: This property ensures that concurrent transactions do not interfere
with each other. It means that the execution of one transaction is isolated from
that of others. This is achieved through locking mechanisms, and it makes
transactions appear to run sequentially, even when they are running at the same
time.46
●​ Durability: This guarantees that once a transaction has been committed, it will
remain committed even in the event of a system failure, such as a power outage
or crash. This is typically achieved by writing transaction logs to non-volatile
storage before the transaction is reported as complete.46

Understanding ACID properties shows that a candidate appreciates the guarantees


that a relational database provides and thinks about data reliability and consistency,
which are critical in any production environment.

Part V: From Theory to Practice - Acing the Assessment

Knowing SQL syntax and theory is the prerequisite, but success in an interview or
online assessment comes from applying that knowledge under pressure to solve
specific problems. This final part bridges the gap between knowledge and
performance, providing a concrete action plan for success by identifying common
problem patterns, recommending practice platforms, and outlining a strategic
approach to the interview itself.

Section 12: Common Interview Question Patterns


While SQL problems can seem infinitely varied, they often fall into a few recurring
patterns. Recognizing these patterns allows a candidate to quickly identify the right
tools and structure for a solution.5
●​ Pattern 1: Filtering and Aggregation ("Give me all X, but...")
○​ Description: This is the most fundamental pattern, forming the basis of many
data analysis tasks. It involves retrieving a set of records, filtering them based
on certain criteria, and then calculating summary statistics.
○​ Core Tools: SELECT, FROM, WHERE, GROUP BY, HAVING.
○​ Example Problem: "For each month, find the count of all Facebook users who
created their account that month, but only for users from a specific country".5
○​ Solution Approach: Use WHERE to filter by country. Use date functions to
extract the month from the creation timestamp. Use GROUP BY on the
extracted month. Use COUNT() to get the number of users in each group.
●​ Pattern 2: Top N per Category
○​ Description: A classic and extremely common problem that asks for the top
(or bottom) N records within specific groups. For example, "find the top 3
highest-paid employees in each department".5
○​ Core Tools: Window Functions (RANK(), DENSE_RANK(), ROW_NUMBER())
with PARTITION BY.
○​ Example Problem: "Find the top 3 employee salaries in each department".5
○​ Solution Approach: Use a CTE. Inside the CTE, use DENSE_RANK()
partitioned by department and ordered by salary descending to assign a rank
to each employee within their department. In the outer query, select from the
CTE where the rank is less than or equal to 3.
●​ Pattern 3: Running Totals / Moving Averages
○​ Description: Common in business and financial analysis, this pattern involves
calculating cumulative metrics over time, such as a running total of sales or a
7-day moving average of user activity.5
○​ Core Tools: Aggregate functions used as window functions (SUM() OVER (...),
AVG() OVER (...)).
○​ Example Problem: "Calculate the 7-day rolling average of daily active users
(DAU)".5
○​ Solution Approach: Use AVG(dau_count) OVER (ORDER BY date ROWS
BETWEEN 6 PRECEDING AND CURRENT ROW). The ROWS BETWEEN clause
defines the moving window.
●​ Pattern 4: Gaps and Islands
○​ Description: An advanced pattern that involves identifying consecutive
sequences (islands) or breaks in a sequence (gaps) in the data. For example,
finding consecutive days a user was active or finding missing ID numbers.15
○​ Core Tools: ROW_NUMBER(), LAG(), LEAD(). A common technique is to create
two row numberings—one over the entire set and one partitioned by a
grouping ID. The difference between these two numbers will be constant for
all rows within a consecutive "island."
○​ Example Problem: "Find the start and end dates of consecutive login periods
for each user."
●​ Pattern 5: Comparing Rows (Self-Joins)
○​ Description: This pattern involves analyzing pairs of items within the same
table. Examples include finding employees who earn more than their
managers, or identifying products that are frequently purchased together.5
○​ Core Tools: SELF JOIN.
○​ Example Problem: "Find all employees who earn more than their managers."
○​ Solution Approach: Join the Employees table to itself, aliasing one as e (for
employee) and the other as m (for manager). The join condition would be
e.manager_id = m.employee_id. The WHERE clause would then be WHERE
e.salary > m.salary.

Section 13: The Gauntlet - Practice Platforms and Problems

Theoretical knowledge must be forged into practical skill through deliberate practice.
Several online platforms provide interactive environments to hone SQL skills for
interviews.48

Platform Analysis

Choosing the right platform depends on your current skill level and learning style. A
strategic approach often involves using a combination of platforms.
●​ SQLZoo: Ideal for absolute beginners. It offers bite-sized, interactive tutorials that
guide users from basic SELECT statements to more advanced concepts in a
structured, easy-to-follow manner. It is entirely browser-based, requiring no
setup.48
●​ LeetCode: A popular platform for general coding interviews, with a substantial
collection of SQL problems. The questions are often algorithmic or puzzle-like
and are categorized by difficulty (Easy, Medium, Hard) and topic.15 The "SQL 50"
study plan is a well-regarded starting point for interview prep.51 While excellent
for mastering complex syntax and functions, some find the problems less
representative of real-world business scenarios.52
●​ HackerRank: Similar to LeetCode, HackerRank offers a wide range of SQL
challenges with difficulty levels from Basic to Advanced. It has a strong emphasis
on skills certification, offering timed assessments that can be used to validate
proficiency to potential employers.48 Its advanced topics include CTEs, window
functions, and query optimization.26
●​ StrataScratch & DataLemur: These platforms are highly praised for providing
practice problems that mirror real-world business cases and actual interview
questions from top tech companies like Meta, Amazon, and Google.48 They are
invaluable for learning how to apply SQL to solve practical business problems,
moving beyond pure syntax to analytical thinking.

Practice Platform Comparison

Platform Problem Style Key Features Best For

SQLZoo Tutorial-Based Interactive, Absolute beginners


step-by-step lessons, learning foundational
browser-based. syntax and
concepts.50

LeetCode Algorithmic / Large problem Mastering complex


Puzzle-Based library, difficulty syntax, window
ratings, "SQL 50" functions, and
study plan, strong algorithmic
community. thinking.48

HackerRank Algorithmic / Basic, Intermediate, Structured learning


Skill-Based and Advanced tracks; paths and formally
official skills validating skills for a
certification tests. resume.48
StrataScratch Real-World / Business Questions from real Practicing how to
Case company interviews solve realistic data
(Meta, Amazon, etc.), analyst and data
multiple SQL dialects. scientist problems.55

DataLemur Real-World / Business Curated collection of Learning common


Case real interview interview patterns
questions, focus on and applying SQL to
common patterns. business KPIs.48

A recommended practice strategy is to start with SQLZoo to build a solid foundation.


Then, move to LeetCode or HackerRank to drill down on specific functions and
complex queries. Finally, spend the majority of your time on StrataScratch and
DataLemur to practice applying those skills in a realistic business context.

Curated Practice Problems

●​ Pattern 1 (Filtering/Aggregation): HackerRank - "Weather Observation Station


4" 10, "Revising Aggregations - The Sum Function".20
●​ Pattern 2 (Top N per Category): LeetCode #185 - "Department Top Three
Salaries" 15, LeetCode #184 - "Department Highest Salary".15
●​ Pattern 3 (Running Totals/Moving Averages): LeetCode #579 - "Find
Cumulative Salary of an Employee" 15, LeetCode #1321 - "Restaurant Growth".15
●​ Pattern 4 (Gaps and Islands): LeetCode #180 - "Consecutive Numbers" 15,
LeetCode #601 - "Human Traffic of Stadium".15
●​ Pattern 5 (Self-Joins): LeetCode #181 - "Employees Earning More Than Their
Managers".15

Section 14: Final Recommendations and Interview Strategy

Success in a technical interview is not just about producing the correct final query. It
is a performance that tests communication, problem-solving, and strategic thinking.
Communicating Your Thought Process

The interviewer wants to understand how you think. A silent candidate who produces
a perfect query is less impressive than a vocal one who explains their approach,
discusses trade-offs, and arrives at a solid solution. Use CTEs as a narrative device to
structure your answer. Walk the interviewer through your logic: "First, I will create a
CTE to filter for active users. Then, I will join that to the orders table..." This makes
your code self-documenting and your thought process transparent.

Clarify, Code, Conclude

Adopt a simple three-step framework for any live coding challenge:


1.​ Clarify: Do not start coding immediately. Repeat the question back to the
interviewer to confirm your understanding. Ask clarifying questions about
potential edge cases: "How should ties in the ranking be handled?", "Are there
NULL values in the key columns, and how should they be treated?", "What is the
expected output format?". State your high-level plan before writing a single line of
code.
2.​ Code: Write clean, well-formatted SQL. Use meaningful aliases for tables and
columns. Use CTEs to break down complex logic. Most importantly, talk through
your logic as you type. Explain why you are choosing a LEFT JOIN over an INNER
JOIN, or why you are using DENSE_RANK() instead of RANK().
3.​ Conclude: Once your query is written, do not just say "I'm done." Briefly test it
against the sample data or edge cases you discussed earlier. If the prompt
allows, mention potential optimizations. A simple statement like, "For a large
dataset, we would want to ensure there is an index on the columns used in the
JOIN and WHERE clauses to prevent a full table scan," can leave a lasting positive
impression.

Ultimately, consistent and strategic practice is the key to building both the skill and
the confidence needed to excel. By mastering the fundamentals, understanding the
theory, recognizing common patterns, and practicing with a clear strategy, any
aspiring data professional can confidently tackle the SQL challenges that stand
between them and their desired role.
Works cited

1.​ SQL Tutorial - GeeksforGeeks, accessed on July 28, 2025,


https://www.geeksforgeeks.org/sql/sql-tutorial/
2.​ SQL Syntax Overview - Tutorialspoint, accessed on July 28, 2025,
https://www.tutorialspoint.com/sql/sql-syntax.htm
3.​ Top 85 SQL Interview Questions and Answers for 2025 | DataCamp, accessed on
July 28, 2025,
https://www.datacamp.com/blog/top-sql-interview-questions-and-answers-for-
beginners-and-intermediate-practitioners
4.​ SQL SELECT | Basic SQL - Mode, accessed on July 28, 2025,
https://mode.com/sql-tutorial/sql-select-statement/
5.​ 5 SQL Interview Patterns You Need To Know (2023 Update), accessed on July 28,
2025, https://datalemur.com/blog/sql-interview-patterns
6.​ SQL Tutorial: Learn SQL from Scratch for Beginners, accessed on July 28, 2025,
https://www.sqltutorial.org/
7.​ Use HAVING and WHERE Clauses in the Same Query (Visual Database Tools),
accessed on July 28, 2025,
https://learn.microsoft.com/en-us/ssms/visual-db-tools/use-having-and-where-cl
auses-in-the-same-query-visual-database-tools
8.​ SQL GROUP BY and HAVING Clauses: A Comprehensive Guide ..., accessed on
July 28, 2025,
https://www.secoda.co/learn/sql-group-by-and-having-clauses-a-comprehensiv
e-guide
9.​ SQL Interview Questions - GeeksforGeeks, accessed on July 28, 2025,
https://www.geeksforgeeks.org/sql/sql-interview-questions/
10.​SQL HackerRank Solutions (Difficulty: Easy) Part I | by Triyoza Aprianda | Medium,
accessed on July 28, 2025,
https://medium.com/@triyoza.aprianda/sql-hackerrank-solutions-difficulty-easy-
part-i-3b39d147fc3a
11.​ Advanced SQL : Subqueries and CTEs | by Datainsights - Medium, accessed on
July 28, 2025,
https://medium.com/@datainsights17/subqueries-and-ctes-in-sql-aa1ff4b17686
12.​SQL Interview Questions CHEAT SHEET (2025) - InterviewBit, accessed on July
28, 2025, https://www.interviewbit.com/sql-interview-questions/
13.​28 SQL interview questions and answers from beginner to senior level -
CodeSignal, accessed on July 28, 2025,
https://codesignal.com/blog/interview-prep/28-sql-interview-questions-and-ans
wers-from-beginner-to-senior-level/
14.​SQL Querying Fundamentals Tutorial - YouTube, accessed on July 28, 2025,
https://www.youtube.com/watch?v=yh92BHmvls8&pp=0gcJCf0Ao7VqN5tD
15.​LeetCode SQL Problems by Problem Domain | Software ..., accessed on July 28,
2025, https://dwf.dev/docs/learning-resources/lc-sql-problems
16.​How to Use GROUP BY, HAVING, and ORDER BY SQL Clauses - Dummies.com,
accessed on July 28, 2025,
https://www.dummies.com/article/technology/programming-web-design/sql/how
-to-use-group-by-having-and-order-by-sql-clauses-160800/
17.​SQL JOIN (With Examples) - Programiz, accessed on July 28, 2025,
https://www.programiz.com/sql/join
18.​SQL Joins | Intermediate SQL - Mode Analytics, accessed on July 28, 2025,
https://mode.com/sql-tutorial/sql-joins/
19.​How to Use GROUP BY and HAVING in SQL - DataCamp, accessed on July 28,
2025, https://www.datacamp.com/tutorial/group-by-having-clause-sql
20.​HackerRank SQL Problem Solving Questions With Solutions - dsfaisal, accessed
on July 28, 2025,
https://www.dsfaisal.com/articles/sql/hackerrank-sql-problem-solving
21.​SQL | GROUP BY - GeeksforGeeks, accessed on July 28, 2025,
https://www.geeksforgeeks.org/sql/sql-group-by/
22.​SQL HAVING Clause with Examples - GeeksforGeeks, accessed on July 28, 2025,
https://www.geeksforgeeks.org/sql/sql-having-clause-with-examples/
23.​Using the SQL HAVING Clause with GROUP BY - Coginiti, accessed on July 28,
2025, https://www.coginiti.co/tutorials/intermediate/sql-having/
24.​Demystifying MySQL Subqueries, Join and Window functions | by Vincent -
Medium, accessed on July 28, 2025,
https://medium.com/@yohanesvincentpangestu/demystifying-mysql-subqueries-
join-and-window-functions-ac40263b0231
25.​SQL Joins: Working with Databases - Dataquest, accessed on July 28, 2025,
https://www.dataquest.io/blog/sql-joins/
26.​SQL (Advanced) | Skills Directory | HackerRank, accessed on July 28, 2025,
https://www.hackerrank.com/skills-directory/sql_advanced
27.​30 Advanced SQL Interview Questions & Answers - UPES Online, accessed on
July 28, 2025, https://upesonline.ac.in/blog/advanced-sql-interview-questions
28.​Advanced SQL Interview Questions and Answers | by Sanjay Kumar PhD -
Medium, accessed on July 28, 2025,
https://skphd.medium.com/advanced-sql-interview-questions-and-answers-307
a5333d02e
29.​Is a CTE basically a named subquery? : r/SQL - Reddit, accessed on July 28, 2025,
https://www.reddit.com/r/SQL/comments/1e2mxex/is_a_cte_basically_a_named_s
ubquery/
30.​CTE in SQL - GeeksforGeeks, accessed on July 28, 2025,
https://www.geeksforgeeks.org/sql/cte-in-sql/
31.​SQL Common Table Expression (CTE) - Syntax, Use Cases, and Examples |
Hightouch, accessed on July 28, 2025,
https://hightouch.com/sql-dictionary/sql-common-table-expression-cte
32.​CTE vs. Subquery | DataLemur, accessed on July 28, 2025,
https://datalemur.com/sql-tutorial/sql-cte-subquery
33.​SQL Common Table Expressions and Window functions - DEV Community,
accessed on July 28, 2025,
https://dev.to/mrpercival/sql-common-table-expressions-and-window-functions-
25ce
34.​Window Functions in SQL - GeeksforGeeks, accessed on July 28, 2025,
https://www.geeksforgeeks.org/sql/window-functions-in-sql/
35.​SQL Window Functions | Advanced SQL - Mode, accessed on July 28, 2025,
https://mode.com/sql-tutorial/sql-window-functions/
36.​SQL Time-Series Window Functions: LEAD & LAG Tutorial - DataLemur, accessed
on July 28, 2025,
https://datalemur.com/sql-tutorial/sql-time-series-window-function-lead-lag
37.​Database Indexing: A Comprehensive Guide for All Levels - DEV Community,
accessed on July 28, 2025,
https://dev.to/iamcymentho/database-indexing-a-comprehensive-guide-for-all-le
vels-1b3m
38.​Ask HN: Can you explain how a database index works in an interview? - Hacker
News, accessed on July 28, 2025,
https://news.ycombinator.com/item?id=14498892
39.​Indexing in Databases - Set 1 - GeeksforGeeks, accessed on July 28, 2025,
https://www.geeksforgeeks.org/dbms/indexing-in-databases-set-1/
40.​How to Implement and Use Database Indexes - Progress Software, accessed on
July 28, 2025, https://www.progress.com/tutorials/odbc/using-indexes
41.​Top 25 SQL interview questions and answers about indexes, accessed on July 28,
2025,
https://www.sqlshack.com/top-25-sql-interview-questions-and-answers-about-i
ndexes/
42.​25 Advanced SQL Interview Questions and How to Answer Them - Final Round AI,
accessed on July 28, 2025,
https://www.finalroundai.com/blog/advanced-sql-interview-questions
43.​Normalization in DBMS - 1NF, 2NF, 3NF, BCNF, 4NF and 5NF | Studytonight,
accessed on July 28, 2025,
https://www.studytonight.com/dbms/database-normalization.php
44.​Database Normalization – Normal Forms 1nf 2nf 3nf Table Examples, accessed on
July 28, 2025,
https://www.freecodecamp.org/news/database-normalization-1nf-2nf-3nf-table-
examples/
45.​Normalization in Relational Databases: First Normal Form (1NF), Second Normal
Form (2NF), and Third Normal Form (3NF) - Vertabelo, accessed on July 28, 2025,
https://vertabelo.com/blog/normalization-1nf-2nf-3nf/
46.​ACID Transactions in Databases | Databricks, accessed on July 28, 2025,
https://www.databricks.com/glossary/acid-transactions
47.​20 Advanced SQL Interview Questions (With Answers!) - DataLemur, accessed on
July 28, 2025, https://datalemur.com/blog/advanced-sql-interview-questions
48.​7 Best Platforms to Practice SQL - KDnuggets, accessed on July 28, 2025,
https://www.kdnuggets.com/2023/01/7-best-platforms-practice-sql.html
49.​How to practice SQL: 10 Best Platforms (2025) - Rivery, accessed on July 28,
2025, https://rivery.io/blog/how-to-practice-sql/
50.​Best Platforms to Practice SQL in 2025 - Interview Query, accessed on July 28,
2025, https://www.interviewquery.com/p/platforms-to-practice-sql
51.​SQL 50 - Study Plan - LeetCode, accessed on July 28, 2025,
https://leetcode.com/studyplan/top-sql-50/
52.​HackerRank advanced SQL problems - Reddit, accessed on July 28, 2025,
https://www.reddit.com/r/SQL/comments/1kqg6wq/hackerrank_advanced_sql_pr
oblems/
53.​Leetcode SQL problems are easy? - Reddit, accessed on July 28, 2025,
https://www.reddit.com/r/SQL/comments/152w0tl/leetcode_sql_problems_are_ea
sy/
54.​SQL (Basic) Skills Certification Test - HackerRank, accessed on July 28, 2025,
https://www.hackerrank.com/skills-verification/sql_basic
55.​StrataScratch: Master Coding for Data Science, accessed on July 28, 2025,
https://www.stratascratch.com/
56.​LeetCode Interesting Sql Problem (Category Hard) : Human traffic of stadium -
Medium, accessed on July 28, 2025,
https://medium.com/@khasnobis.sanjit890/leetcode-interesting-sql-problem-cat
egory-hard-human-traffic-of-stadium-4e50aeeb2dd5

You might also like