Hey everyone,
I have a table called callClassificationRecords as follows.
CallCode1 CallCode2 CallCode3 CallCode4 CallCode5
1 13 55 198 44
3 1 87 9 3
55 3 1 9 13
Now for the explaination..... This table is inside of an application where a data entry clerk can classify a call based on a predefined sheet of call codes, example, when someone calls into this company they call about "Complaints" that call gets marked in the application with a value of 1, "reset password" calls are marked with call code "9", etc. A call can have multiple call code values, hense why I have five columns for them to input types of calls on. I know that this is not normalized nor the proper way to do this, however, I did not design this database, nor did I want too...
The query I need is as follows, it will need to do a sort of count/mode statisitical function that will show me the call code value and a count of every time the value occurs in the five columns...
For example,
Call Code 1 = 3 occurances
Call Code 9 = 2 occurances
Call Code 3 = 3 occurances, etc for each unique call code ( there are 200 call codes in total, so there are a possiblity of 200 unique call codes)
I have been programming for around 2 years, I know that in programming I could do a recursive function to do this inside of a for loop. However I have NO idea how to do this in a SQL function. I did run across the following query online,
SELECT callCode1 AS [Call Code 1], COUNT(*) AS Frequency
FROM callClassificationRecords
GROUP BY callCode1
This query does what I want it to, however it only does it for 1 column at a time, I need it to do that for all five columns...
Please HELP!!!! I am desperate....
Thanks,
Alex
Start Free Trial