Using Functions
SQL provides various functions that you can use in the SELECT statement to perform calculations or manipulate data. Here’s an example:
SELECT first_name, last_name, YEAR(hire_date) AS hire_year FROM employees;
This query will retrieve the “first_name” and “last_name” columns from the “employees” table, along with the year of hire extracted from the “hire_date” column using the YEAR function.
Subqueries
A subquery is a query nested inside another query. It can be used to retrieve data based on the result of another query. Here’s an example: