gpt4 book ai didi

mysql - 独特的案例陈述

转载 作者:行者123 更新时间:2023-11-30 00:51:13 25 4
gpt4 key购买 nike

我试图仅返回“1”或“0”,而不是同时返回 Case 语句中当前出现的情况。我目前的声明如下。如果名字下有任何 O,那么我需要显示它而不是“1”。如果没有“0”,那么我想显示“1”。感谢您的帮助。

SELECT Distinct Room,   
Unit,
Number,
(LastN +', '+ FirstN) AS Name,

min( CASE WHEN Ques1_Yes = '0' THEN '0'
WHEN Ques2_Yes = '0' THEN '0'
WHEN Ques3_Yes = '0' THEN '0'
WHEN Ques4_Yes = '0' THEN '0'
WHEN Ques6_Yes = '1' THEN '0'
WHEN Name IS NULL THEN '-1'
ELSE '1'
END AS Direction

FROM Customer_Service.dbo.Name
WHERE Name = 'smiff, jess'

现在我想知道如何让它发挥作用。抱歉,我对 sql 比较陌生

最佳答案

也许像这样?

SELECT 
min( CASE WHEN Ques1_Yes = '0' THEN '0'
WHEN Ques2_Yes = '0' THEN '0'
WHEN Ques3_Yes = '0' THEN '0'
WHEN Ques4_Yes = '0' THEN '0'
WHEN Ques6_Yes = '1' THEN '0'
WHEN Name IS NULL THEN 'NULL'
ELSE '1'
END) AS Direction

FROM Customer_Service.dbo.Name
WHERE Name = 'smiff, jess'

关于mysql - 独特的案例陈述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20951078/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com