oraclel case when
时间: 2023-08-27 13:20:27 浏览: 164
在Oracle中,CASE WHEN语句用于在查询中根据条件返回不同的值。可以使用CASE WHEN语句来对数据进行条件判断和转换。下面是一个示例:
SELECT CASE
WHEN CreateTime > '2019-02-14 16:24:42' THEN '之后'
WHEN CreateTime < '2019-02-14 16:24:42' THEN '之前'
ELSE 'now'
END stage
FROM table_login
ORDER BY CreateTime DESC;
这个语句将根据CreateTime的值返回不同的阶段信息,如果CreateTime大于'2019-02-14 16:24:42',则返回'之后',如果CreateTime小于'2019-02-14 16:24:42',则返回'之前',否则返回'now'。其中table_login为查询的表名,CreateTime为表中的列名。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Oracle / Mysql 的 case when then else end 用法](https://blog.csdn.net/beguile/article/details/102557454)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [给力 MySQL 和oracle中 case when用法](https://blog.csdn.net/zhou123905524/article/details/100008638)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文