You now know two types of SQL commands, namely:
- Data Definition Language
- Data Manipulation Language
The
Data Definition Language (DDL) is used to create and modify the schema
of the database. Commands like CREATE, ALTER and DROP are part of this
language.
As a data analyst, you would always be actively involved in data retrieval activities. Here, the Data Manipulation Language (DML) commands would come in handy, e.g. the DML command SELECT, its purpose, various clauses and filtering operations.
Order by Clause
The SQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Some databases sort the query results in an ascending order by default.
The basic syntax of the ORDER BY clause is as follows −
SELECT column-list
FROM table_name
[WHERE condition]
[ORDER BY column1, column2, .. columnN] [ASC | DESC];
The order in which it appears is “select * from table where some_variable = x order by some_variable”.
Read More…