更新时间:2023-10-23 GMT+08:00
简单表达式
逻辑表达式
逻辑表达式的操作符和运算规则,请参见逻辑操作符。
- is distinct from/is not distinct from
伪列
ROWNUM
ROWNUM是一个伪列,它返回一个数字,表示从查询中获取结果的行编号。第一行的ROWNUM为1,第二行的为2,依此类推。
ROWNUM的返回类型为BIGINT。ROWNUM可以用于限制查询返回的总行数,例如下面语句限制查询从Students表中返回最多10条记录。
select * from Students where rownum <= 10;
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
openGauss=# SELECT 2 BETWEEN 1 AND 3 AS RESULT; result ---------- t (1 row) openGauss=# SELECT 2 >= 1 AND 2 <= 3 AS RESULT; result ---------- t (1 row) openGauss=# SELECT 2 NOT BETWEEN 1 AND 3 AS RESULT; result ---------- f (1 row) openGauss=# SELECT 2 < 1 OR 2 > 3 AS RESULT; result ---------- f (1 row) openGauss=# SELECT 2+2 IS NULL AS RESULT; result ---------- f (1 row) openGauss=# SELECT 2+2 IS NOT NULL AS RESULT; result ---------- t (1 row) openGauss=# SELECT 2+2 ISNULL AS RESULT; result ---------- f (1 row) openGauss=# SELECT 2+2 NOTNULL AS RESULT; result ---------- t (1 row) openGauss=# SELECT 2+2 IS DISTINCT FROM NULL AS RESULT; result ---------- t (1 row) openGauss=# SELECT 2+2 IS NOT DISTINCT FROM NULL AS RESULT; result ---------- f (1 row) |
父主题: 表达式