Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
anilr499
Starting Member
18 Posts |
Posted - 2012-05-10 : 22:27:19
|
| will some body help me.....This is my query:select C_PROJECT,avg(CAST(kpi as decimal(10,2))) as avr from kpitable where KPI is not null group by c_projectc_project avr Performance Mgmt & Delivery 1.492753RACE (Vendor, Contract Mgmt) 1.875000Portfolio 1.750000Data Conversion/Integration 1.700000Functional & Process 2.638888Post Live Readiness 3.000000Technical Architecture 2.363636Business Process Design & BCP 3.250000Functional, Product & Parameter 2.982456GL Accounting & Regulatory Reporting 2.750000Knowledge Management & Training 2.250000Testing 2.500000Infrastructure Assessment 2.882352in the above query am getting the average of kpi depending on c_project....but now i need another column of average ...which is the avg of whole kpi...some thing like this ....select avg(CAST(kpi as decimal(10,2))) as totavr from kpitable WHERE KPI is not nullbut in this am getting only one column and row ...totavr2.421188According to my requirement ...this totavr should repeat for every distinct c_project....finally my table should be like this.....c_project avr totavrPerformance Mgmt & Delivery 1.492753 2.421188RACE (Vendor, Contract Mgmt) 1.875000 2.421188Portfolio 1.750000 2.421188Data Conversion/Integration 1.700000 2.421188Functional & Process 2.638888 2.421188Post Live Readiness 3.000000 2.421188Technical Architecture 2.363636 2.421188Business Process Design & BCP 3.250000 2.421188Functional, Product & Parameter 2.982456 2.421188GL Accounting & Regulatory Reporting 2.750000 2.421188Knowledge Management & Training 2.250000 2.421188Testing 2.500000 2.421188Infrastructure Assessment 2.882352 2.421188thank you |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-10 : 22:31:18
|
| [code]select C_PROJECT,avg(CAST(kpi as decimal(10,2))) as avr ,Totavr from (select *,avg(CAST(kpi as decimal(10,2))) over () as Totavr from kpitable where KPI is not null )tgroup by c_project,Totavr [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
anilr499
Starting Member
18 Posts |
Posted - 2012-05-10 : 22:43:32
|
quote: Originally posted by visakh16
select C_PROJECT,avg(CAST(kpi as decimal(10,2))) as avr ,Totavr from (select *,avg(CAST(kpi as decimal(10,2))) over () as Totavr from kpitable where KPI is not null )tgroup by c_project,Totavr ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ thank you i got it....
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-10 : 22:48:43
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|