[英]For an id if a value is ever false than it's always false SQL
I have a data set where I created a value that based on some criteria I get True/False based on some prior values. 我有一个数据集,我创建了一个基于某些条件的值,我根据一些先前的值得到了True / False。 Now if my member is ever a False they need to have 1 record in which they are always False.
现在如果我的成员永远是假的,他们需要有1条记录,它们总是假的。 Data is similar to below
数据类似于下面
ID| Indicator
1 | TRUE
1 | TRUE
2 | FALSE
3 | TRUE
3 | FALSE
I want it to look like this 我希望它看起来像这样
ID | Indicator
1 | TRUE
2 | FALSE
3 | FALSE
But I'm not sure how to do this in Teradata 但我不知道如何在Teradata中做到这一点
Teradata does not support a boolean type. Teradata不支持布尔类型。 So, I will assume the indicator is a string.
所以,我会假设指标是一个字符串。
In that case, the simplest method is min()
: 在这种情况下,最简单的方法是
min()
:
select id, min(indicator)
from t
group by id;
Based on sample data, i would do : 根据样本数据,我会这样做:
SELECT DISTINCT t.id,
(CASE WHEN EXISTS (SELECT 1
FROM table t1
WHERE t1.id = t.id AND t1.Indicator = 'False'
)
THEN 'False'
ELSE 'TRUE'
END) AS Indicator
FROM table t;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.