case when.then.else.endSQL实现如下功能用case when...then...else.end 实现当A=1时,那么B=1,否则B=0;C=0,否则C=1

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/06 04:01:45
casewhen.then.else.endSQL实现如下功能用casewhen...then...else.end实现当A=1时,那么B=1,否则B=0;C=0,否则C=1casewhen.then

case when.then.else.endSQL实现如下功能用case when...then...else.end 实现当A=1时,那么B=1,否则B=0;C=0,否则C=1
case when.then.else.end
SQL实现如下功能
用case when...then...else.end 实现
当A=1时,那么B=1,否则B=0;C=0,否则C=1

case when.then.else.endSQL实现如下功能用case when...then...else.end 实现当A=1时,那么B=1,否则B=0;C=0,否则C=1
首先你要搞清楚case when的用法
case when最终得到的结果是一个值,而不是多个值,更不是赋值.你写的就是赋值了.
你是要更新么?
update 表 set b = (case A when 1 then 1 else 0 end),c = (case A when 1 then 0 else 1 end)
一定要写两次才行.
如果查询语句,那么B和C应该是你构建的两个列了
select (case A when 1 then 1 else 0 end) as B,
(case A when 1 then 0 else 1 end) as C
from 表
case when也可以写成
case when A = 1 then 1 else 0 end这样的形式.
不管怎么写,你要记住,case when语句,得到的是一个值,而不是在里面赋值.
因为你写的并不明确,所以大家都搞不清楚你到底是要更新B列和C列还是要查询

case when then else end CASE a WHEN 1 THEN b ELSE NULL END --简单Case函数 CASE sex WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE '其他' END --Case搜索函数 CASE请问这两种用法有什么区别,分别在什么情况下使用?--简单Case函数 CASE sex WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE case when.then.else.endSQL实现如下功能用case when...then...else.end 实现当A=1时,那么B=1,否则B=0;C=0,否则C=1 SUM(CASE WHEN ISNULL(A.ReceiveQty,0)>0 THEN 1 ELSE 0 END) AS SumReceiveRolls是什么意思?在储存过程中,这句是什么意思SUM(CASE WHEN ISNULL(A.ReceiveQty,0)>0 THEN 1 ELSE 0 END) AS SumReceiveRolls, 这段文字的意思update student  set grade = (  select grade from  (  select id,  case when score> 90 then 'a'  when score > 80 then 'b'  when score > 70 then 'c'  else 'd' end grade  from student  ) a case when then else end 能用在条件判断上么比如select * from app a where --在这加case when 可以么?select * from app a where case when a.id = 1 then a.name = '22' else a.name = '33' CASE WHEN LEN(GY_YGDM.YSSFZH)>0 THEN left(CAST(GY_YGDM.YSSFZH AS VARCHAR(32)),18) ELSE '-' END AS s求详解 sql case when then ...虚心求教select case salarywhen 5000 then '高薪'when 4500 then '中薪'when 3500 then '中低薪'else 'null'end as '工资等级' from telenolist我想统计各个工资级别的人数 那个count(*)应该放在语句的哪 (case A.ZT when 1 then 's318' else null end)SELECT A.*,CONVERT(NVARCHAR(50),B.JJRQ,23) AS JJRQ FROM BXX A,JJD B where A.JJDBH=B.JJDBH and A.BZBH='YZ1-81-01' and A.SMARBH = (case A.ZT when 1 then 's318' else null end) ORDER BY B.JJRQ,A.BZBHA.SMARBH = 这是什么SQL语法啊,从未见过,以下是全文select sc.cid as 课程ID,course.name as 课程名,SUM(CASE WHEN score BETWEEN 85 AND 100 THEN 1 ELSE 0 END) AS [100 - 85],SUM(CASE WHEN score BETWEEN 70 AND 85 THEN 1 ELSE 0 END) AS [85-70],SUM(CA select * top 99 percent from 职工 order by case when 工资 is null then 1 else 0 end 哪里出错了select * top 99 percent from 职工 order by case when 工资 is null then 1 else 0 end为什么总说有不能识别的短语或关键字 这语句什么意思select * from [Feedbacks] where QId=3 order by case when QId=3 then 1 else 2 end,QId这个语句什么意思select * from [Feedbacks] where QId=3 order by case when QId=3 then 1 else 2 end,QId select CNAME=case when CNAME is null then '4' else '1' end from SMPTEL where SMPTEL.Newtel='1585'select CNAME=case when CNAME is null then '456' else '123' end from SMPTEL where SMPTEL.Newtel='158'Newtel 没有158 如何让其显示 456现在 c#开发cast( (case when b.pbproject_ID is null then 1 else 0 end) as bit ) as if (Convert.ToBoolean(this.grvQuery.GetDataRow(i)[xz]) == true){selected = true;}上面那个是条件 SQL server中哪些语句中运用逻辑表达式?请回答除了:where ,if(else if),while,case when..then..,having,on越多越好,最好能有简单例子. if-then-else是什么意思 sql case when请教请教sql中case when 判断语句select 姓名,工龄,(case when (工龄>= '35') then 90%when (工龄>='30' and 工龄='20' and 工龄='10' and 工龄