表达式是一个或多个值,运算符和SQL函数计算结果的值的组合。
SELECT column1, column2, columnN FROM table_name WHERE [CONDITION|EXPRESSION];
1.布尔表达式
SQL> SELECT * FROM CUSTOMERS WHERE SALARY = 10000;
2.数字表达式:
这个表达式用来在任何查询执行任何数学运算。下面是语法:
SELECT numerical_expression as OPERATION_NAME
[FROM table_name WHERE CONDITION] ;
SQL> SELECT (15 + 6) AS ADDITION
还有像一些内置函数avg(), sum(), count()等,执行了被称为数据计算对表或特定的表列集合体。
SELECT COUNT(*) AS "RECORDS" FROM CUSTOMERS;
3.日期表达式:
日期表达式返回当前系统日期和时间值:
SQL> SELECT CURRENT_TIMESTAMP;
+---------------------+| Current_Timestamp |
+---------------------+| 2009-11-12 06:40:23 |
+---------------------+1 row in set (0.00 sec)
SQL> SELECT GETDATE();;
| GETDATE |+-------------------------+|
2009-10-22 12:07:18.140