通过case when 进行更细致的分类
##################################################
####### 参考 #######

如果没有添加case when 最终的sql 语句 就只是查询表中的name
而且添加 case when [age] >= 18 then 1 else 0 end as [AgeType]
记就表示找表中的两个字段 一个是name 另一个是AgeType,而且 AgeType 的值是根据age 进行判断的。
简单理解为,当age >= 18是 AgeType == 1 否则 ==0

本文介绍了如何在SQL查询中使用casewhen关键字,根据年龄条件(age>=18)动态为AgeType字段赋值,实现对表中数据的细致分类。
3633

被折叠的 条评论
为什么被折叠?



