How To Learn SQL

Shailendra Dubey
3 min readMar 2, 2022

Hello everyone, this is Shailendra Dubey. If you are someone who is learning SQL from scratch or you are someone who has already learned SQL but still, you are struggling or not very much confident then this blog is for you. Now in this blog, I am going to explain to you the step-by-step guide on “How to learn SQL?”

SQL is a Structured Query Language, which is a computer language for storing, manipulating, and retrieving data stored in a relational database. It is a very important language to learn for a data analyst but it is also very important to learn it in a proper way. In my opinion, the correct way that we should follow while learning SQL is —

1.)Understand the fundamentals

2.) Learn the SQL commands

3.)Practice writing basic SQL queries

4.)Practice writing intermediate SQL queries

5.)Practice writing advanced SQL queries

Let's see the different topics that you should learn in the following five steps—

1.)Understand The Fundamentals:-

If you have started learning SQL, then in the very first step you must get familiar with the following terms:

  • What are Data, Database, And RDBMS?
  • What is SQL and what is the intention of using it?
  • How do Companies store data in their database server?

2.)Learn SQL Commands:-

After being familiar with fundamentals, you should learn various SQL commands. The different SQL commands are as follows —

these are some important commands that you should try to learn as a beginner.

3.) Practice Writing Basic SQL Queries:-

If you have learned the different SQL commands then you should try to create some sample tables and insert data into them and start writing some basic queries using comparison operators (=,<>,!=,<,>,≥,≤), arithmetic operators (+,-,*,/,%), logical operators (AND, OR, NOT, IN, BETWEEN, LIKE), solve some SQL queries using a CASE statement, learn how to use DISTINCT and LIMIT clause and see how results changes when you use these clauses. You should also try to learn ORDER By clause to understand how to sort your result in various orders. And finally, you should try to fetch data from multiple tables using an INNER join.

4.)Practice Writing Intermediate Queries:-

Now you should start writing intermediate Queries in the following way —

  • Try writing SQL Queries where you use the three different types of subqueries such as Scalar Subquery, Multi-Row Subquery, and Correlated Subquery.
  • Try writing some queries using Group By because this is the one that we use most of the time.
  • Try writing some query using different aggregate functions like MIN,MAX,SUM,AVG,COUNT,etc.
  • Try writing some query using different joins such as LEFT join, RIGHT join, FULL OUTER join, CROSS join, etc.
  • Try to write some queries using inbuilt date conversion functions like to_date or date_format or CAST etc.
  • Try to write some queries using inbuilt string functions to fetch part of a text from data.

5.) Practice Writing Advanced SQL Queries:-

After practicing for intermediate SQL queries, you should try to write advanced SQL queries using different concepts —

  • Try to write some queries using SELF join because self join can help you in many ways to solve problems which may seem you impossible to solve using SQL Query.
  • Try to write some queries using WITH Clause.
  • Try to write some queries using Windows functionsas it is one of the best features to solve complex queries. Use different Windows functions such as row_number, rank, dense_rank, first_value,last_value,lead,lag, etc.

To practice all the above concepts you will require some database which contains some sample tables.Download sample database of amazon,swiggy, etc from internet.

Thank You for Reading!

--

--

Shailendra Dubey

Hi there, there are many things to tell but in short, I am an inspired Data Scientist who is trying to use mathematics in the Data Science domain effectively.