Search code examples
sqlteradatateradata-sql-assistant

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. Now if my member is ever a False they need to have 1 record in which they are always False. 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


Solution

  • Teradata does not support a boolean type. So, I will assume the indicator is a string.

    In that case, the simplest method is min():

    select id, min(indicator)
    from t
    group by id;