Hi, I have a sort of stupid table structure on the project I inherited. It's a list of what work was performed that uses codes like this:
CustomerID | Date | Code1 | Code2 | Code3 | Code4
I want to know all work that was performed for a certain period and thus need to count the distinct codes on codes 1-4.
Say I have the test data:
1 | today | AA | AB | AC | Null
2 | today | AC | BB | Null | Null
I want to get the following:
AA | 1
AB | 1
AC | 2
BB | 1
The table is pretty huge so I need an effective query... Any hints?
graabein
CustomerID | Date | Code1 | Code2 | Code3 | Code4
I want to know all work that was performed for a certain period and thus need to count the distinct codes on codes 1-4.
Say I have the test data:
1 | today | AA | AB | AC | Null
2 | today | AC | BB | Null | Null
I want to get the following:
AA | 1
AB | 1
AC | 2
BB | 1
The table is pretty huge so I need an effective query... Any hints?
graabein