SQL - Expressions: Syntax
SQL - Expressions: Syntax
An expression is a combination of one or more values, operators, and SQL functions that evaluate to a value. SQL EXPRESSIONs are like formulas and they are written in query lang uag e. You can also use them to query the database for specific set of data.
Syntax:
Consider the basic syntax of the SELECT statement as follows:
SELECT column1, column2, columnN FROM table_name WHERE [CONDITION|EXPRESSION];
T here are different types of SQL expressions, which are mentioned below:
Here numerical_expression is used for mathematical expression or any formula. Following is a simple examples showing usag e of SQL Numeric Expressions:
SQL> SELECT (15 + 6) AS ADDITION +----------+ | ADDITION | +----------+ | 21 | +----------+ 1 row in set (0.00 sec)
T here are several built-in functions like avg (), sum(), count(), etc., to perform what is known as ag g reg ate data calculations ag ainst a table or a specific table column.
SQL> SELECT COUNT(*) AS "RECORDS" FROM CUSTOMERS; +---------+ | RECORDS | +---------+ | 7 | +---------+ 1 row in set (0.00 sec)