Hi,
I have to create a query that checks across several different columns, and if any of them have a 1, I want to return true.
Ideal output would be along the lines of:
ID:55
Name:John Doe
IsDealerType1:True
IsDealerType2:True
IsDealerType3:False
IsDealerType4:False
IsDealerType5:True
The problem is, instead of those 5 dealer columns, I have about 20 columns named 1a, 1b, 1c, 1d, etc. If any of the "1" columns is true, then IsDealerType1 should be true.
I'm trying to avoid writing something in the VB.NET code to check each and every column, just because that sheer ugliness should be easy to avoid in SQL - if only I knew how to do it - but I'm not sure how to construct the query. I've been trying stuff like...
SELECT id,
name,
(1a or 1b or 1c or 1d) as IsDealerType1,
(2a or 2b or 2c or 2d) as IsDealerType2
where id = 55
... but obviously, I'm not doing it right.
Any help is appreciated. Thanks!