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 |
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2009-07-31 : 04:09:22
|
| Dear All,I have a query i need to calculate the running total for Efficiency column.. pls help me it is very urgent SELECT convert(varchar,ReportingMonth.Month,106) as month, ReportingMonth.PlantID, ISNULL(Efficiency.Eff, 0) AS Efficiency,baselineEfficiency, 1 as todisplayin1page FROM (SELECT TOP (100) PERCENT ReportingMonth_1.Month, Plant.PlantID,plant.baselineEfficiency FROM Plant CROSS JOIN ReportingMonth AS ReportingMonth_1 WHERE (ReportingMonth_1.Month BETWEEN DATEADD(mm, - 1, GETDATE()) AND DATEADD(mm, 83, GETDATE())) and plant.plantid='PBG'ORDER BY ReportingMonth_1.Month, Plant.PlantID,plant.baselineEfficiency) AS ReportingMonth LEFT OUTER JOIN (SELECT TOP (100) PERCENT PlantID, DATEADD(dd, - DAY(P50Unit1Date) + 1, P50Unit1Date) AS Month, SUM(P50Fraction * P50Efficiency / 100) AS Eff FROM FanOut AS F where F.plantid='PBG' GROUP BY PlantID, DATEADD(dd, - DAY(P50Unit1Date) + 1, P50Unit1Date) ORDER BY PlantID, Month) AS Efficiency ON ReportingMonth.PlantID = Efficiency.PlantID AND ReportingMonth.Month = Efficiency.Month order by ReportingMonth.Monthyour help will be appreciated. |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
|
|
|
|
|
|
|