【SQL】1873. 计算特殊奖金(CASE WHEN;IF())

题目描述

leetcode题目:1873. 计算特殊奖金


Code

写法一: CASE WHEN

sql 复制代码
select employee_id, 
    (case when employee_id % 2 = 0 or name like 'M%' then salary = 0 else salary end) as bonus
from Employees
order by employee_id

写法二 :IF()

sql 复制代码
select employee_id, 
    if(employee_id % 2 = 0 or name like 'M%', 0, salary) as bonus
from Employees
order by employee_id
相关推荐
alphaTao17 小时前
LeetCode 每日一题 2026/9/21-2026/9/27
python·算法·leetcode
fb_1234517 小时前
MySQL基础核心|数据库原理+MySQL详解
数据库·mysql
‎ദ്ദിᵔ.˛.ᵔ₎17 小时前
Mysql 基本查询
数据库·mysql
-madongyu-17 小时前
GaussDB 性能调优:等待事件、慢 SQL 定位与关键参数
数据库·sql·gaussdb
-madongyu-18 小时前
GaussDB 部署规划:磁盘水位、RAID 与端口设计
数据库·gaussdb
weixin_511255211 天前
MySQL升级记录
数据库·mysql
程序猿乐锅1 天前
【黑马点评 | 第八篇】Redisson分布式锁
java·数据库·spring boot·redis·分布式·spring·缓存
Leo.yuan1 天前
2026年本地化Data Agent优质厂商盘点:哪些产品更适合企业生产环境
大数据·数据库·人工智能
做运维的阿瑞1 天前
数据库增删改的安全写法
数据库·sql·mysql
程序边界1 天前
迁移评估不再拍脑袋,这个数据迁移工具的量化报告把我救了(上)
数据库