1. 列名或列引用:
SELECT column1 FROM your_table;
2. 常量:
SELECT 'Hello, World!' AS greeting FROM dual;
3. 算术表达式:
SELECT column1 + column2 AS sum_result FROM your_table;
4. 比较表达式:
SELECT * FROM your_table WHERE column1 > 100;
5. 逻辑表达式:
SELECT * FROM your_table WHERE column1 > 100 AND column2 < 50;
6. 字符串操作:
SELECT CONCAT(column1, ' ', column2) AS full_name FROM your_table;
7. 聚合函数:
SELECT AVG(column1) AS average_value FROM your_table;
8. CASE表达式:
SELECT
column1,
CASE
WHEN column2 > 100 THEN 'High'
WHEN column2 > 50 THEN 'Medium'
ELSE 'Low'
END AS priority
FROM your_table;
9. 窗口函数:
SELECT
column1,
ROW_NUMBER() OVER (ORDER BY column1) AS row_num
FROM your_table;
10. 日期和时间函数:
SELECT
column1,
TO_DATE(column2, 'YYYY-MM-DD') AS formatted_date
FROM your_table;
这些是一些在OceanBase SQL查询中使用的简单表达式。你可以根据具体的业务需求将它们组合起来,构建复杂的查询和计算逻辑。
转载请注明出处:http://www.pingtaimeng.com/article/detail/11718/OceanBase