How to get the opposite of a function

I am trying to improve a work macro that we use.

What I am trying to do is to create a new value (false) if an element is not part of a data blaze table's column.

Here is a sample query for a {dbselect}

SELECT "false" AS clientyn
FROM clients
WHERE includes(client_ids, @clientID)

What I am asking is if there is away to get the opposite of includes, so that I can return false, since returning "true" gives a mistake when I want to use a row where I do not have any client IDs

I have tried to use NOT in front of includes but it does not resolve the issue.

Here is my table
image
XD sorry for blacking out everything but I am unable to show any of the ids or names

Hi @yani10634,

I think you want to select "false" if a particular ID is not present in the client_ids column across all rows. So you can select rows where it is present and check if their count is 0 like this

SELECT ("false" if countagg() = 0 else "true") AS clientyn
FROM clients
WHERE includes(client_ids, @clientID)

If this doesn't serve your use case, please let me know.

1 Like