Advertisement

11.07.2005 at 09:50PM PST, ID: 21622836
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

SQL Query, URGENT!!! Need help with mode function inside sql query.....

Asked by alex_hannah in MS SQL Server

Tags: , ,

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
[+][-]11.07.2005 at 09:56PM PST, ID: 15245276

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: sql, function, mode
Sign Up Now!
Solution Provided By: ram2098
Participating Experts: 2
Solution Grade: A
 
 
[+][-]11.07.2005 at 10:18PM PST, ID: 15245341

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.07.2005 at 10:22PM PST, ID: 15245358

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.07.2005 at 11:23PM PST, ID: 15245538

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.07.2005 at 11:54PM PST, ID: 15245629

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.08.2005 at 06:54AM PST, ID: 15247654

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32