How to Learn SQL
for Data Analysis?
step-by-step Guide to learn in 2025!
SQL
1. Understand the Basics of SQL
Get familiar with SQL syntax, data types, and basic commands.
2. Practice Basic SQL Queries
Practice SELECT statements, filtering with WHERE, sorting with
ORDER BY, and using basic functions like COUNT, AVG, and SUM.
3. Learn About Data Aggregation and Grouping
Master GROUP BY, HAVING, and aggregate functions to
summarize data.
4. Understand Joins and Subqueries
Learn to combine data from multiple tables using JOINs (INNER,
LEFT, RIGHT, FULL) and write subqueries.
5. Learn Data Manipulation
Understand how to modify data using INSERT, UPDATE, DELETE,
and learn transaction control.
6. Master Advanced SQL Functions
Explore advanced functions like CASE, COALESCE, string functions,
date functions, and window functions (e.g., ROW_NUMBER, RANK).
7. Work on Real-World Projects
Apply your knowledge to real datasets and solve practical
business problems using Kaggle Datasets
SQL Roadmap 02
Types of SQL Command
Data Definition Language (DDL)
Defines & modifies the structure of database objects like tables & indexes.
Create Update Delete Drop Insert Alter Merge
Data Manipulation Language (DML)
Manages and manipulates data within tables, including inserting, updating,
and deleting records.
Update Delete Insert Merge
Data Control Language (DCL)
Control access to data in the database, ensuring security and proper
permissions.
GRANT REVOKE
Transaction Control Language (TCL)
Manage transactions within a database to ensure data integrity and
handle errors.
COMMIT ROLLBACK SAVEPOINT SET TRANSACTION
Data Query Language (DQL)
Primarily used for querying the database to retrieve data.
select
SQL Roadmap 03
SQL Functions used
for Data Analysis
Aggregate Functions
SUM(): Calculates the total sum of a numeric column.
SELECT SUM(column_name) FROM table_name WHERE condition;
AVG(): Returns the average value of a numeric column.
SELECT AVG(column_name) FROM table_name WHERE condition;
COUNT(): Counts the number of rows that match a specified condition.
SELECT COUNT(column_name) FROM table_name WHERE condition;
MAX(): Finds the maximum value in a column.
SELECT MAX(column_name) FROM table_name WHERE condition;
SQL Roadmap 04
MIN(): Finds the minimum value in a column.
SELECT MIN(column_name) FROM table_name WHERE condition;
String Functions
CONCAT(): Combines two or more strings into one.
SELECT CONCAT(string1, string2, ...) AS combined_string FROM table_name;
SUBSTRING(): Extracts a substring from a string based on position.
SELECT SUBSTRING(column_name, start_position, length) AS substring
FROM table_name;
LENGTH(): Returns the length of a string.
SELECT LENGTH(column_name) AS string_length FROM table_name;
UPPER()/LOWER(): Converts a string to uppercase or lowercase.
SELECT UPPER(column_name) AS uppercase_string FROM table_name;
SQL Roadmap 05
SELECT LOWER(column_name) AS lowercase_string FROM table_name;
TRIM(): Removes leading and trailing spaces from a string.
SELECT TRIM(column_name) AS trimmed_string FROM table_name;
Date Functions
NOW(): Returns the current date and time.
SELECT NOW() AS current_datetime;
DATEPART(): Extracts a part (e.g., year, month) from a date.
SELECT DATEPART(part, date_column) AS extracted_part FROM table_name;
SELECT DATEPART(YEAR, date_column) AS year FROM table_name;
DATEDIFF(): Calculates the difference between two dates.
SELECT DATEDIFF(end_date, start_date) AS date_difference FROM table_name;
SQL Roadmap 06
DATEADD(): Adds or subtracts a specified time interval from a date.
SELECT DATEADD(interval, number, date_column) AS new_date FROM
table_name;
SELECT DATEADD(DAY, 7, date_column) AS new_date FROM table_name;
FORMAT(): Formats a date into a specified format.
SELECT FORMAT(date_column, 'format_string') AS formatted_date FROM
table_name;
SELECT FORMAT(date_column, 'yyyy-MM-dd') AS formatted_date FROM
table_name;
Mathematical Functions
ROUND(): Rounds a number to a specified number of decimal places.
SELECT ROUND(numeric_column, decimal_places) AS rounded_number
FROM table_name;
SQL Roadmap 07
FLOOR()/CEIL(): Returns the largest integer less than or equal to a
number, or the smallest integer greater than or equal to a number.
SELECT FLOOR(numeric_column) AS floored_number FROM table_name;
SELECT CEIL(numeric_column) AS ceiled_number FROM table_name;
ABS(): Returns the absolute value of a number.
SELECT ABS(numeric_column) AS absolute_value FROM table_name;
POWER(): Raises a number to a specified power.
SELECT POWER(numeric_column, exponent) AS power_result FROM table_name;
Window Functions
RANK(): Provides a rank to rows within a partition of a result set, with
gaps for ties.
SELECT column_name, RANK() OVER (ORDER BY column_name) AS rank
FROM table_name;
SQL Roadmap 08
ROW_NUMBER(): Assigns a unique sequential integer to rows within
a result set.
SELECT column_name, ROW_NUMBER() OVER (ORDER BY column_name) AS
row_num FROM table_name;
NTILE(): Distributes rows into a specified number of approximately
equal-sized groups.
SELECT column_name, NTILE(num_buckets) OVER (ORDER BY column_name)
AS bucket FROM table_name;
LAG()/LEAD(): Accesses data from the previous or next row in the
result set.
SELECT column_name, LAG(column_name, offset, default_value) OVER
(ORDER BY column_name) AS previous_value FROM table_name;
SELECT column_name, LEAD(column_name, offset, default_value) OVER
(ORDER BY column_name) AS next_value FROM table_name;
SQL Roadmap 09
Conditional Functions
CASE: Allows for conditional logic within SQL queries.
SELECT CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
ELSE default_result
END AS alias_name
FROM table_name;
COALESCE(): Returns the first non-null value in a list of arguments.
SELECT COALESCE(column1, column2, ...) AS first_non_null_value
FROM table_name;
NULLIF(): Compares two expressions and returns NULL if they are
equal.
SELECT NULLIF(expression1, expression2) AS result FROM table_name;
P.S : Learn to integrate SQL with data visualization tools like
Tableau or Power BI.
SQL Roadmap 10
Wanna
Become
Top 1%
of Data
Analysts?
DM “1%” for 1:1 Consultation