An expression is a combination of one or more values, operators and SQL functions that evaluate to a value. These SQL EXPRESSIONs are like formulae and they are written in query language. You can also use them to query the database for a specific set of data.
Consider the basic syntax of the SELECT statement as follows −
There are different types of SQL expressions, which are mentioned below −
Let us now discuss each of these in detail.
SQL Boolean Expressions fetch the data based on matching a single value. Following is the syntax −
Consider the EMPLOYEES table having the following records −
The following table is a simple example showing the usage of various SQL Boolean Expressions −
These expressions are used to perform any mathematical operation in any query. Following is the syntax −
Here, the numerical_expression is used for a mathematical expression or any formula. Following is a simple example showing the usage of SQL Numeric Expressions −
There are several built-in functions like avg(), sum(), count(), etc., to perform what is known as the aggregate data calculations against a table or a specific table column.
Date Expressions return current system date and time values −
Another date expression is as shown below −