Back to articles list Articles Cookbook
6 minutes read

The SQL Syntax Is Simple: True or False?

Are you contemplating learning SQL but are concerned about how difficult it may be, especially if you have no prior coding experience? If so, you are not alone. In this article, I show you how simple SQL is and that it is worth your time learning it. You just need to know how to approach it properly.

Many people carry the notion that learning SQL is much like learning other programming languages. They think it requires you to understand a complex syntax of code and a myriad of computer science or IT concepts.

Well, good news! This is not true at all. You have to spend some effort learning the SQL syntax for sure. But learning SQL is a much faster and easier journey compared to learning other programming languages like Java or C++.

Once you grasp the basics well, your learning takes off. The learning resources available online today add fuel to the fire to accelerate your learning. I encourage you to check out the A to Z SQL learning track from LearnSQL.com. Its structured content, abundant practice queries, and comprehensive coverage of basic concepts, all spread over 7 SQL courses and 84 hours of learning time, give you a wonderful foundation in SQL.

Another reason SQL is easy to learn is that it is quite intuitive. If you understand the syntax of a basic query and some simple concepts, you can easily adapt it for the specific results you are looking for.

Let me walk you through some practical examples to substantiate my claim.

The SQL Syntax, Compared to Java

Imagine you have a very simple requirement. You want to store the names of four customers and then retrieve these names in alphabetical order.

Here is how a typical Java code would look.

import java.io.*;
class SortAlphabetical {
    public static void main(String[] args)
    {
        // store number of elements
        int n = 4;
        // array for storing names
        String listofnames[]
            = { "Emily", "Bram", "Francesca", "Bob" };
        String temp;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                // linear sorting
                if (listofnames[i].compareTo(listofnames[j]) > 0) {
                    // swapping
                    temp = listofnames[i];
                    listofnames[i] = listofnames[j];
                    listofnames[j] = temp;
                }
            }
        }
        
        // printing
        System.out.println(
            “Here is the list of names: ");
        for (int i = 0; i < n; i++) {
            System.out.println(listofnames[i]);
        }
    }
}

Output:

Here is the list of names:
Bob
Bram
Emily
Francesca

Well, this may take some time for someone just starting in programming to understand.

Now, take a look at how you typically handle this in SQL. You create a table called Customers, insert the names, and then write a simple SELECT query. This is how that looks:

CREATE TABLE Customers
(Customer_Name varchar(30));

INSERT INTO Customers VALUES (‘Emily’);
INSERT INTO Customers VALUES (‘Bram’);
INSERT INTO Customers VALUES (‘Bob’);
INSERT INTO Customers VALUES (‘Francesca’);

SELECT Customer_Name
FROM Customers
ORDER BY Customer_Name;

Output:

Customer_Name
Bob
Bram
Emily
Francesca

You notice how close the SQL syntax is to your everyday English. You create a table with a certain name (Customers) with a column named Customer_Name of the type character, insert some records, and then retrieve (select) Customer_Name from the table in a particular order (ascending alphabetical order). Seems easy, right?

This is an extremely simple example of how SQL works. Let me take you through some more detail to explain why learning SQL is useful.

Why Is It Important to Learn SQL?

Not only is SQL simple to understand compared to other programming languages, but also it has great use cases for making everyday business decisions smarter and data-supported. This is what makes SQL a wonderful tool to have in your arsenal.

Here is a practical example for you to consider. Imagine you work in the marketing department of a guitar manufacturing company that sells guitars online. You have acquired some customers online and are now thinking about opening a physical store. You need to decide in which city. To gauge the demand for your brand by city, you want to use the sales data you have collected so far.

In your database, the data related to customer orders are in a table called Orders. Also, the customer details are stored in a table named Customers. Each table has several rows in the following format:

Orders

Customer_IdItem TypeItem_IdOrder_IdLine_Total
123Acoustic GuitarPS-32-1d332$200
122Electric GuitarYA-12-1e332$800

Customers

Customer_IdCustomer_NameAgeOccupationCity
123Emily31332Paris
122Jack22332New York

Query

SELECT a.City as City,
 COUNT(DISTINCT a.Customer_Id) as Number_Of_Customers,
 SUM(b.Line_Total) as Total_Order_Value
FROM   Customers a
LEFT JOIN Orders b
ON a.Customer_id = b.Customer_Id
GROUP BY a.City
ORDER BY 3 Desc;

Output

CityNumber_Of_CustomersTotal_Order_Value
Paris24,000$120,000
London30,000$100,000
New York21,000$90,000
Delhi65,000$80,000

The query works by joining the two tables by the Customer_Id column. The records from both tables are retrieved where this condition matches. Then, the results are grouped or aggregated by City and then finally printed in descending order by Total_Order_Value.

Don’t worry if you don’t understand it in detail at this stage. You can take the course on basic SQL queries from LearnSQL.com to develop your understanding of these queries.

This example is a very foundational use case of how you use a simple SQL syntax to generate valuable insights for business. You may be in marketing, finance, sales, operations, HR, IT, or some other non-IT function, be it at a well-established firm or a start-up. SQL is amazing for just about anyone who works with data and databases. Imagine what you can do with more data and queries!

Another great thing about SQL is that the syntax is quite similar across the top databases no matter which database you work with. You don’t need to learn SQL repeatedly to switch between databases. A database may have some specific differences, but the basic concepts remain quite similar, and you pick up just on those differences.

The SQL Syntax Is Simple!

I hope you feel much more at ease about the SQL syntax after reading this article. You can be confident about beginning your SQL learning journey.

If you are still not sure, just start writing your first few queries. You will be writing the most advanced queries before you even realize it. Soon, you generate money for yourself and your business with the ideas you uncover.

Given the boost learning SQL gives your career and your business, it is one of the first things you should learn when it comes to data analytics. So, what are you waiting for? Get started today!