任務 #376
進行中
處理一所需要的近十年「降雨量同期比較」所需要的資料
是由 康文龍 於 4 個月 前加入.
於 4 個月 前更新.
完成日期:
2024-07-31 (逾期 約 4 個月)
概述
因共計3千多萬筆資料處理速度較慢,分兩階段作業處理:
- 先提供近十年降雨量資料
- 再調整相關功能語法優化
檔案
近十年530~730資料平均值¶
;With Source
as
(
select distinct GridNumber, DataYear, SUM(case when Rain<0 then 0 else Rain end) as [DataValue]
from tbl_GridCumulativeDailyRainfallOneToThree a
where DataYear >=2004 and DataYear<=2023 and DataDate between '05-30' and '07-30' and GridSize=3
group by GridNumber, DataYear
--order by GridNumber, DataYear
)
select a.GridNumber, b.Latitude, b.Longitude, AVG(DataValue) as DataValue
from Source a inner join tbl_GridInfo b on b.GridSize=3 and b.GridNumber=a.GridNumber
group by a.GridNumber, b.Latitude, b.Longitude
order by a.GridNumber
2024-08-01 取得近十年網格平均降雨量料¶
-- =============================================
-- Author:RECO
-- Create date: 2024/08/01
-- Description: 取得近十年網格的降雨量資料
-- exec sp_GetTenYearGridInfo '05-30', '07-30'
-- =============================================
Create Procedure sp_GetTenYearGridInfo
(
@StartDate varchar(5),
@EndDate varchar(5)
)
as
Begin
-- 設定要統計的啟始日期
if (@StartDate='' or Len(@StartDate)=0)
Begin
Set @StartDate='01-01'
End
-- 設定要統計的結束日期
if (@EndDate='' or Len(@EndDate)=0)
Begin
Set @EndDate='12-31'
End
-- 取得網格資料
;With Source
as
(
select distinct GridNumber, DataYear, SUM(case when Rain<0 then 0 else Rain end) as [DataValue]
from tbl_GridCumulativeDailyRainfallOneToThree a
where DataYear >=2014 and DataYear<=2023 and DataDate between @StartDate and @EndDate and GridSize=3
group by GridNumber, DataYear
--order by GridNumber, DataYear
)
select a.GridNumber, b.Latitude, b.Longitude, AVG(DataValue) as DataValue
from Source a inner join tbl_GridInfo b on b.GridSize=3 and b.GridNumber=a.GridNumber
group by a.GridNumber, b.Latitude, b.Longitude
order by a.GridNumber
End
匯出至 Atom
PDF