diff --git a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs index d6e6847..4ddf88c 100644 --- a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs +++ b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs @@ -55,12 +55,12 @@ namespace SolarPower.Repository.Implement sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( - SELECT - SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, - SUM(TOTALCARBON) AS All_Carbon - from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a - LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP + SELECT + SUM(ps.Total_kwh) AS All_kwh, + SUM(ps.total_money) AS All_money, + SUM(ps.total_carbon) AS All_Carbon + FROM power_station ps + WHERE ps.Id IN @ids ) AS m, ( @@ -116,12 +116,12 @@ namespace SolarPower.Repository.Implement sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( - SELECT - SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, - SUM(TOTALCARBON) AS All_Carbon - from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a - LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP + SELECT + SUM(ps.Total_kwh) AS All_kwh, + SUM(ps.total_money) AS All_money, + SUM(ps.total_carbon) AS All_Carbon + FROM power_station ps + WHERE ps.Id IN @ids ) AS m, ( @@ -151,12 +151,12 @@ namespace SolarPower.Repository.Implement case 2: sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( - SELECT - SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, - SUM(TOTALCARBON) AS All_Carbon - from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a - LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP + SELECT + SUM(ps.Total_kwh) AS All_kwh, + SUM(ps.total_money) AS All_money, + SUM(ps.total_carbon) AS All_Carbon + FROM power_station ps + WHERE ps.Id IN @ids ) AS m, ( @@ -189,12 +189,12 @@ namespace SolarPower.Repository.Implement case 3: sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( - SELECT - SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, - SUM(TOTALCARBON) AS All_Carbon - from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a - LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP + SELECT + SUM(ps.Total_kwh) AS All_kwh, + SUM(ps.total_money) AS All_money, + SUM(ps.total_carbon) AS All_Carbon + FROM power_station ps + WHERE ps.Id IN @ids ) AS m, (