Skip to content
Advertisement

How to count the number of occurences for a specific value from a range of columns using T-SQL?

I have a table (t1) as shown below that contains single-character values in all columns named v%:

I need to count the number of occurrences for “O” and “E” and display them in 2 additional columns. How can I do this?

Expected Output:

Advertisement

Answer

I would use apply and aggregation:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement