Many occupations rely on SQL for data retrieval and management. Since SQL is robust and easy to learn, some job portals consider it the most in-demand skill an employee can have. Here is a quick introduction to SQL.
What is SQL?
Structured Query Language, abbreviated as SQL, is an ANSI standard language designed to operate and manage databases. Using SQL you can:
- Execute queries against and retrieve data from a database.
- Insert, update and delete records in a database.
- Create new databases, tables, procedures and views.
- Set user permissions on tables, procedures and views.
SQL Order of Operations
SQL has a list of commands/clauses which need to be written in a particular order. Here is the basics to getting this order right:
- SELECT (selects data from a database).
- FROM (specifies the table you're pulling data from).
- WHERE (acts as a filter to match a specified condition).
- GROUP BY (groups data into logical sets).
- HAVING (acts like the WHERE clauses specifically for groups).
- ORDER BY (sets the order of results, followed by DESC for descending order or ASC for ascending order).
SQL Query Example
Below is an example of a query written using all the commands specified in the order of operations to give you an idea of how this is done in practice:
This query does contain a few other clauses and expressions that have not been covered in this blog which I plan on writing about in the future, but I hope this example demonstrates how SQL queries are written.