'How to use ANY and ALL operators in SQL to compute a value?

Given two tables: Foo <----- Boo

I would like to compute Foo.status and add it to the sql query based on the Boo values.

select *, status from Foo;

In python code, I do the following to generate the status of Foo but I would like to have it be part of the sql query.

How to use ANY and ALL operators directly in SQL to add a status column to the query?

def get_status:
    boos = foo.boos.all()

    if all([i.value1 - i.value2 == 0 for i in boos]):
        return "status1"

    if all([i.value2 == 0 for i in boos]):
        return "status2"

    if any([i.value2 > 0 for i in boos]):
        return "status3"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source