Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivot Table Results in SQL Server 2005 1

Status
Not open for further replies.

larrydavid

Programmer
Jul 22, 2010
174
US
Hello,

Here is sample output from a stored proc which predefines the values, so I cannot do any further calculations or manipulations on these fields:

Code:
RowID	MetricName	TIN	SUFFIX	UCL	LCL
1	Dollars_Billed	43129981	29	69866.05556	412852.7395
2	Dollars_Paid	43129981	29	46731.83333	352863.0205
3	Paid_Bill_Ratio	43129981	29	7.611111	85.77652105
4	Dollars_Billed	43129981	33	54870.5	406396.2158
5	Dollars_Paid	43129981	33	51361.77778	353614.1411
6	Paid_Bill_Ratio	43129981	33	2.888888	87.41923158

Here is the result I would like, where the MetricName fiels has its values separated into columns:

Code:
RowID	TIN	SUFFIX	Dollars_Billed	Dollars_Paid	Paid_Bill_Ratio	UCL	LCL
1	43129981	29	25,879	65,743	93,347	69866.05556	412852.7395
2	43129981	29	35,779	23,747	65,453	46731.83333	352863.0205
3	43129981	29	30,719	23,047	5,453	7.611111	85.77652105
4	43129981	33	43,746	57,777	3,983	54870.5	406396.2158
5	43129981	33	21,999	8,717	365.423	51361.77778	353614.1411
6	43129981	33	21,909	11,768	45.453	2.888888	87.41923158

I'm having a hard time getting my head around this. I hope this makes sense.

Any help would be greatly appreciated.

Thanks,
Larry
 
So basically you want to add fields Dollars_Billed, Dollars_Paid, Paid_Bill_Ratio and you want to remove MetricName?

Do you have access to copy or change the SP?

Do you have calculations for Dollars_Billed, Dollars_Paid, Paid_Bill_Ratio or if these are fields some where else can you join back to the origial tables to get the new fields?

Simi
 
Hi Simi,

I have been able to arrive at another solution, but your feedback got me thinking in the right direction. Thank you for your time.

Regards,
Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top