博客
关于我
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/

    你可能感兴趣的文章
    NOAA(美国海洋和大气管理局)气象数据获取与POI点数据获取
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    node exporter完整版
    查看>>
    node HelloWorld入门篇
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node JS: < 二> Node JS例子解析
    查看>>
    Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime(72)
    查看>>
    Node 裁切图片的方法
    查看>>
    Node+Express连接mysql实现增删改查
    查看>>
    node, nvm, npm,pnpm,以前简单的前端环境为什么越来越复杂
    查看>>
    Node-RED中Button按钮组件和TextInput文字输入组件的使用
    查看>>
    vue3+Ts 项目打包时报错 ‘reactive‘is declared but its value is never read.及解决方法
    查看>>
    Node-RED中Switch开关和Dropdown选择组件的使用
    查看>>
    Node-RED中使用exec节点实现调用外部exe程序
    查看>>
    Node-RED中使用html节点爬取HTML网页资料之爬取Node-RED的最新版本
    查看>>
    Node-RED中使用JSON数据建立web网站
    查看>>
    Node-RED中使用json节点解析JSON数据
    查看>>
    Node-RED中使用node-random节点来实现随机数在折线图中显示
    查看>>
    Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
    查看>>
    Node-RED中使用node-red-contrib-image-output节点实现图片预览
    查看>>