SQL 101: Introduction to SQL for Data Analysis
Tags: sql, database, python
Published: 2023-02-18 20:15:57


**Structured query language (SQL)** 
is a programming language for storing and processing information in a relational database. A relational database stores information in tabular form, with rows and columns representing different data attributes and the various relationships between the data values.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/63abo8g48f194vhdu0wb.jpg)

                   **Advantages of SQL**
SQL has several benefits that have helped it become increasingly popular in the field of data science. It’s a wonderful query language for data professionals and users to interface with databases. The advantages or benefits of SQL are as follows:

**_Query Processing at a High Speed_**
SQL queries are used to obtain a large volume of data from the database fast and efficiently. Data activities such as insertion, deletion, and updating take less time.
_**There is no need to code.**_
For database management, SQL does not need a huge amount of coding lines. Using basic SQL syntactical rules, we can quickly access and maintain the database.


**_Flexibility_**
Desktop computers, laptops, tablets, and even smartphones may all use the structured query language. It can also be used in concert with other programming languages, depending on the needs of the user.

_**Language is defined**_
SQL adheres to ISO and ANSI standards, which provide a consistent platform for all of its users across the world.

                **Disadvantages of SQL**

It also has disadvantages which are as follows:

**_Price_**
Some SQL versions have a significant operating cost. As a result, some developers don’t use SQL.

**_The User Interface Is Complicated_**
Another significant downside is that the Structured query language interface is complex, making it difficult for SQL users to use and administer.

_**Database control its portion**_
The business regulations are kept under wraps. As a result, data professionals and users who utilize this query language are unable to have complete database control.

There are some most commonly used SQL commands:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2mychg89mskv9fesytsw.jpg)


CREATE command.
SELECT command.
INSERT command.
DROP command.
DELETE command.

**SQL CREATE DATABASE Command**

CREATE DATABASE database_name;

**SQL CREATE TABLE Command**
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,

**SQL SELECT Command**

SELECT column1, column2....columnN
FROM   table_name;

**SQL INSERT INTO Command**
INSERT INTO table_name( column1, column2....columnN)
VALUES (value1, value2....valueN);

**SQL DROP DATABASE Command**

DROP DATABASE database_name;

**SQL DROP TABLE Command** 

DROP TABLE table_name;

**SQL DELETE Command**

DELETE FROM table_name
WHERE{CONDITION};

There are other commands that are also used, like:

**SQL WHERE Clause**

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION;

**SQL AND/OR Clause**

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION-1 {AND|OR} CONDITION-2;

**SQL IN Clause**

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name IN (val-1, val-2,...val-N);

**SQL BETWEEN Clause**

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name BETWEEN val-1 AND val-2;

**SQL LIKE Clause**

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name LIKE { PATTERN };

**SQL ORDER BY Clause**

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION
ORDER BY column_name {ASC|DESC};

**SQL GROUP BY Clause**

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name;

**SQL COUNT Clause**

SELECT COUNT(column_name)
FROM   table_name
WHERE  CONDITION;

**SQL HAVING Clause**

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name
HAVING (arithematic function condition);
columnN datatype,
PRIMARY KEY( one or more columns )
);

**SQL CREATE UNIQUE INDEX Command**

CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...columnN);
SQL DROP INDEX Command
ALTER TABLE table_name
DROP INDEX index_name;
SQL DESC Command
DESC table_name;


SQL in data analysis is a standardized language that is used to query or retrieve data from a relational database.
Within languages like Python, Scala, and Hadoop, which are most popular currently in use for data science along with big data management and manipulation.

**What skills are needed for data analyst?**

**Programming Knowledge:** As an SQL Data Analyst, one must be fluent in writing scripts, and queries and must know other Programming Languages as well.
 **Advanced Computer Skills:** The job role of a SQL Analyst also requires advanced computer knowledge. They must have basic knowledge on the hardware of devices.