×

sql select case

sql select case(sql语句中的的select case 问题)

admin admin 发表于2023-10-10 20:59:03 浏览42 评论0

抢沙发发表评论

本文目录

sql语句中的的select case 问题

SELECT sum(case when age 》20 and age 《30 then 1 else 0 end) as FROM Student---以上,希望对你有所帮助。

SQL的SELECT语句,里面可以嵌套CASE么

可以的,而且使用频率还比较高。例:字段:性别 以1和2,分别代表男和女xb 121那么检索的时候可以写:select case when xb = ’1’ then‘男’when ’2’ then ’女’ else ’’ end

SQL语句用法: select case语句块后面能否加where 条件

when。。。。。。。。。then。。。。。。。 when就相当於wherecreate table table_3(a varchar ,b varchar)insert into table_3 values(’1’,’2’)insert into table_3 values(’1’,’3’)insert into table_3 values(’2’,’2’)select * from table_3---when语句中的类型和else必须一致select (case a when ’1’ then’123’ when ’2’ then ’456’ else 0 end ) as aa ,a,b from table_3select case when a=1 then ’中文’ when a=2 then ’英文’ else ’过问’ endfrom table_3