Is it possible to count the number of columns that match certain conditions
and return a single value?
For example in the database we have a record where:
Column 1 = Male
Column 2 = A
Column 3 = B
Column 4 = D
Column 5 = M
And the data to be used for the query is:
Column 1 = Male
Column 2 = D
Column 3 = B
Column 4 = Z
Column 5 = M
I would like to be able to return all records where Column 1 = Male and also
return how many columns (from Column 2 through 5) match the data input. In
this case the number would be 2 since Column 3 and Column 5 in the database
match the data used for the query. If no columns match the input data, the
number returned would be 0.
Does that make sense? Can anybody help me out with a sql statement that
will do this? It would be greatly appreciated.
Thanks!