博客
关于我
Mysql ---- case的使用及case的嵌套
阅读量:798 次
发布时间:2023-02-10

本文共 590 字,大约阅读时间需要 1 分钟。

  • case的使用
  • 在SQL中,CASE语句是一种强大的工具,可以用来实现数据分类、转换或逻辑判断。本文将介绍CASE语句的基本用法以及实际应用场景。
    以下是一个典型的CASE语句示例:
    case OperationHistory.OperationName 	when 'RetrieveContainers'		then '出库'	when 'RemoveMaterial' 		then '出库' 	when 'StoreContainers' 		then '入库' 	when 'PutMaterial' 		then '入库' end as type1
    1. case的嵌套
    2. CASE语句可以嵌套使用,以实现更复杂的逻辑判断。本文将展示如何在嵌套结构中使用CASE语句来实现更灵活的数据处理。
      以下是一个嵌套CASE语句的示例:
      case type1 	when '出库' 		then 			case status1 				when '1' 					then null 				when '2' 					then '2' 			ELSE null             END 	when '入库' 		then 			case status1 				when '1' 					then '1' 				ELSE null 			ENDEND AS statuss

    转载地址:http://klffk.baihongyu.com/

    你可能感兴趣的文章
    Nacos配置中心中配置文件的创建、微服务读取nacos配置中心
    查看>>
    Nacos配置中心集群原理及源码分析
    查看>>
    nacos配置在代码中如何引用
    查看>>
    nacos配置新增不成功
    查看>>
    nacos配置自动刷新源码解析
    查看>>
    nacos集成分布式事务插件Seata的序列化问题,实际上是Seata本身存在bug!!
    查看>>
    Nacos集群搭建
    查看>>
    nacos集群搭建
    查看>>
    nacos集群网络分区对的影响和运维方式
    查看>>
    nacos集群节点故障对应用的影响以及应急方法
    查看>>
    nacos集群配置详解
    查看>>
    Nagios 3.0 Jumpstart Guide For Linux – Overview, Installation and Configuration
    查看>>
    nagios 实时监控 iptables 状态
    查看>>
    WAP短信格式解析及在Linux下用C语言实现
    查看>>
    nagios+cacti整合
    查看>>
    Nagios介绍
    查看>>
    nagios利用NSCient监控远程window主机
    查看>>
    nagios安装文档
    查看>>
    nagios服务端安装
    查看>>
    Nagios自定义监控脚本
    查看>>