There are an interesting query problem I am facing. I am trying solve using single query, opposite to use of temporary tables or string concatenation functions.
Basically, I have Table “T” with an integer id and 6 populated columns A, B, C, D, E, F with integer values. I have to populate columns A1, A2, A3, A4, A5, A6 where:
A1 value should be populated with the number of occurrences of value in the field A over fields A, B, C, D, E, F in the same row
B1 value should be populated with the number of occurrences of value in the field B over fields A, B, C, D, E, F in the same row
Etc…
Sample of values with calculated values for A1, A2, A3, A4, A5, A6 after running a query should be: