SQL Commands Every Data Analyst Should Know
SkillVeris Team
Data Science Team

SQL commands fall into four categories: data definition, data manipulation, data query, and data control.
In this guide, you'll learn:
- SELECT is the most frequently used SQL command, retrieving data from one or more tables based on specified conditions.
- INSERT, UPDATE, and DELETE handle adding, changing, and removing rows of data.
- JOIN clauses combine data from multiple related tables into a single result set.
- WHERE, GROUP BY, and ORDER BY refine, aggregate, and sort query results.
1What Are SQL Commands?
SQL commands are instructions used to create, retrieve, update, and manage data stored in a relational database. SQL, or Structured Query Language, is the standard language for interacting with databases like PostgreSQL, MySQL, and SQL Server.
Commands are grouped into categories based on what they do: defining structure, manipulating data, querying data, or controlling access.
2Categories of SQL Commands
SQL commands are organized into four main categories, each serving a distinct purpose.
- Data Definition Language (DDL): CREATE, ALTER, and DROP define and modify database structure like tables and columns.
- Data Manipulation Language (DML): INSERT, UPDATE, and DELETE add, change, and remove data within tables.
- Data Query Language (DQL): SELECT retrieves data from one or more tables.
- Data Control Language (DCL): GRANT and REVOKE manage user permissions on database objects.
3The SELECT Statement
SELECT retrieves data from a table, and is the command analysts use most often when working with a database.
A basic SELECT specifies which columns to return and from which table, and can be combined with clauses that filter, sort, and group the results.
- SELECT column1, column2 FROM table_name;
- SELECT * FROM table_name; retrieves all columns.
- SELECT DISTINCT column1 FROM table_name; returns only unique values.
4Filtering With WHERE
The WHERE clause filters rows based on a condition, returning only the rows that match rather than the entire table.
Conditions can use comparison operators, ranges, pattern matching, or lists of values, and can be combined using AND and OR.
- SELECT * FROM orders WHERE status = 'shipped';
- SELECT * FROM orders WHERE total > 100 AND region = 'West';
- SELECT * FROM customers WHERE name LIKE 'A%';
5Modifying Data: INSERT, UPDATE, DELETE
Three core commands handle changes to the actual data stored in a table.
INSERT adds new rows, UPDATE changes existing rows that match a condition, and DELETE removes rows that match a condition. Each of these should generally include a WHERE clause when targeting specific rows, since omitting it applies the change to the entire table.
- INSERT INTO customers (name, email) VALUES ('Jane Doe', '[email protected]');
- UPDATE customers SET email = '[email protected]' WHERE id = 42;
- DELETE FROM customers WHERE id = 42;
💡
6Joining Tables
JOIN clauses combine rows from two or more tables based on a related column, which is essential since relational databases store data across multiple linked tables rather than one flat file.
An INNER JOIN returns only rows with matches in both tables. A LEFT JOIN returns all rows from the first table plus matches from the second, filling in blanks where there is no match.
Example
Combining an orders table with a customers table to show the customer name alongside each order.
SELECT orders.id, customers.name FROM orders INNER JOIN customers ON orders.customer_id = customers.id;7Grouping and Sorting Results
GROUP BY and ORDER BY shape how query results are aggregated and presented.
GROUP BY combines rows sharing a value into a single summary row, typically paired with an aggregate function like COUNT or SUM. ORDER BY sorts the final result set by one or more columns, ascending or descending.
- SELECT region, COUNT(*) FROM orders GROUP BY region;
- SELECT * FROM orders ORDER BY total DESC;
8Defining Structure With DDL Commands
CREATE, ALTER, and DROP manage the structure of the database itself rather than the data inside it.
CREATE TABLE defines a new table and its columns. ALTER TABLE changes an existing table's structure, such as adding a column. DROP TABLE removes a table entirely, including all its data, and should be used with caution.
9Next Steps
Mastering these core SQL commands covers the vast majority of real-world querying and data manipulation tasks analysts encounter daily.
SkillVeris's SQL for Data Analytics course and related interview question guides on databases go deeper into query optimization, subqueries, and advanced joins for readers ready to build on these fundamentals.
Related Reading
Get The Print Version
Download a PDF of this article for offline reading.
About the Publisher
SkillVeris Team
Data Science Team
Our data team shares real-world analytics, ML, and SQL insights grounded in industry practice.
View all postsRelated Posts
Never miss an update
Get the latest tutorials and guides delivered to your inbox.
No spam. Unsubscribe anytime.