Counting the min (or max) number of the occurrence of a word across multiple columns in sql

12 Views Asked by At

I'm teaching myself SQL and Excel and I'm trying to practice using some data sets.

Please help me with this thought. I'm trying to create this new column called "Flu". I need to count the min number of the occurrence of the word "true" across 3 columns and then based on this number populate this new column "Flu". I'm thinking something like below:

CASE WHEN MIN (# of "true") >=2 THEN 1 ELSE 0 END AS "FLU"

But my understanding is that CASE WHEN works down a column and not necesarrily across columns. I appreciate your comments.

was thinking of a conditional statement such as:

CASE WHEN MIN (# of "true") >=2 THEN 1 ELSE 0 END AS "FLU"

0

There are 0 best solutions below