SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Makaio780
Starting Member

Canada
24 Posts

Posted - 08/10/2012 :  12:35:23  Show Profile  Reply with Quote
Current Table:

Count | Priority | Classification
32 Low A
41 Medium A
52 High A
30 Critical A
18 Low B
99 Medium B
54 High B
70 Critical B

Query:
Select count(Incident_Number)as Count,Priority,Classification
From vars76_hpd_help_desk inner join
vTbl_Remedy_Group_Classification ON vARS76_HPD_Help_Desk.Assigned_Group = vTbl_Remedy_Group_Classification.Group_Name
where (status = 'Assigned' or status = 'New' or status = 'Pending' or status = 'in progress')
Group by Priority,Classification
ORDER BY Classification



How can i make it so it shows as:


Classification | Low | Medium | High | Critical
A 32 41 52 30
B 18 99 54 70



Ron Cheung

Makaio780
Starting Member

Canada
24 Posts

Posted - 08/10/2012 :  12:40:49  Show Profile  Reply with Quote
Also once i get the data in that format how would i insert that info into a new table?


Ron Cheung
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/10/2012 :  15:42:27  Show Profile  Reply with Quote
pivot it to get data in desired format

select Classification,[Low],[Medium],[High],[Critical]
from
(
Select Incident_Number,Priority,Classification
From vars76_hpd_help_desk inner join
vTbl_Remedy_Group_Classification ON vARS76_HPD_Help_Desk.Assigned_Group = vTbl_Remedy_Group_Classification.Group_Name
where (status = 'Assigned' or status = 'New' or status = 'Pending' or status = 'in progress')
)t
PIVOT (COUNT(Incident_number) FOR Priority IN ([Low],[Medium],[High],[Critical]))p
ORDER BY Classification


for inserting above into table
just use

INSERT into table
above select statement

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Makaio780
Starting Member

Canada
24 Posts

Posted - 08/10/2012 :  16:41:50  Show Profile  Reply with Quote
Thank you so much!!!

Ron Cheung
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/10/2012 :  17:03:57  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000