1. 简单的列选择:
SELECT column1, column2 FROM your_table;
2. 列运算和重命名:
SELECT column1 + column2 AS sum_result, column3 * 2 AS doubled_value FROM your_table;
3. 使用聚合函数:
SELECT AVG(column1) AS average_value, COUNT(column2) AS row_count FROM your_table;
4. 日期和时间表达式:
SELECT TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD') AS formatted_date, EXTRACT(YEAR FROM column1) AS year_part FROM your_table;
5. 逻辑表达式和条件表达式:
SELECT
column1,
CASE
WHEN column2 > 100 THEN 'High'
WHEN column2 > 50 THEN 'Medium'
ELSE 'Low'
END AS priority
FROM your_table;
6. 子查询表达式:
SELECT
column1,
(SELECT MAX(column2) FROM another_table) AS max_value
FROM your_table;
7. 连接多个表并选择列:
SELECT
your_table.column1,
another_table.column2
FROM
your_table
JOIN
another_table ON your_table.id = another_table.id;
8. 使用窗口函数:
SELECT
column1,
ROW_NUMBER() OVER (ORDER BY column2) AS row_num
FROM your_table;
这些表达式列表中的每一个表达式都负责定义查询结果中的一个列或一个计算结果。你可以根据实际需求组合和调整这些表达式,以获取符合你查询目的的结果。
转载请注明出处:http://www.zyzy.cn/article/detail/11726/OceanBase