Solved

SQL Query Help - Something like Pivot

Posted on 2011-03-17
3
270 Views
Last Modified: 2012-05-11
Team,

Need your help.

I have a table with some data on it. Please find attached a sample look of the table.

 Sample File
What i really want to do is, %  of escalated cases by team.

Escalation % per team =  Number of Escalations for the day / Number of cases handled for the day.

I cannot run pivot queries in my SQL as it doesnt support.

requesting your help to find the desired result in a query.

Thanks,
David
0
Comment
Question by:davidi1
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35156685
select Team
, count(*) total_cases
, sum(case when Status = 'Escalation' then 1 else 0 end) escalations
, cast( sum(case when Status = 'Escalation' then 1 else 0 end) as decimal(20,2)) /  count(*) perc_esc
from yourtable
group by team
0
 
LVL 2

Author Comment

by:davidi1
ID: 35156877
AngelIII - Thank you.., but am looking for per day per team percentage.., sorry if my question was confusing.
0
 
LVL 2

Author Comment

by:davidi1
ID: 35156901
Perfect. I made the changes with dates. Thanks again for your help
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now