0
我試圖執行以下查詢甲骨文 - ORA-01848錯誤
SELECT w.grid_no, SUM(A)
FROM TABLE_1 w
WHERE w.DAY between to_date((select jsow from TABLE_2 t where t.grid_no = w.grid_no and t.crop_no=90) || '-2016','DDD-YYYY') - 0
and to_date((select jsow from TABLE_2 t where t.grid_no = w.grid_no and t.crop_no=90) || '-2016','DDD-YYYY') + 0 + 10 - 1
and A > 8
group BY w.GRID_NO
,但我有錯誤
01848. 00000 - "day of year must be between 1 and 365 (366 for leap year)"
相反,如果我添加上grid_no查詢工作的過濾器;例如
SELECT w.grid_no, SUM(A)
FROM TABLE_1 w
WHERE w.grid_no=1000 -- <---- the added filter
and w.DAY between to_date((select jsow from TABLE_2 t where t.grid_no = w.grid_no and t.crop_no=90) || '-2016','DDD-YYYY') - 0
and to_date((select jsow from TABLE_2 t where t.grid_no = w.grid_no and t.crop_no=90) || '-2016','DDD-YYYY') + 0 + 10 - 1
and A > 8
涉及的兩個表是:
TABLE_1 [grid_no, day, A]
TABLE_2 [grid_no, crop_no, jsow]
JSOW是儒略日:對於給定的一對(grid_no,crop_no)存儲在表2的最大值可以去從1到366
我的目標是有這樣的事情:對於TABLE_1中的每個grid_no,我必須在TABLE_2中獲取相應的jsow值,然後在通過jsow指定的範圍中求和A值。
錯誤提示你實際上有'jsow'值不在1和366之間? –
@AlexPoole我檢查了:MIN(jsow)= 1,MAX(jsow)= 366。 grid_id = 1000(請參閱第二個查詢)擁有jsow = 366 – Fab
網格ID 1000顯然具有良好的jsow值,而其他網格則沒有。你是說'select min(jsow),max(jsow)from table_2'在* all * grid ID中顯示1和366,或者只顯示1000?如果它適用於所有ID,那麼是否帶有'crop_no = 90'過濾器? –