我正在尝试使用以下查询创建视图。
SELECT the_day, t1, t2
FROM year_days
LEFT JOIN (SELECT tea_prodcution_date, SUM(quantity) t1
FROM TEA_PRODUCTION
WHERE field_name like 'T1'
GROUP BY tea_prodcution_date) ON the_day = tea_prodcution_date
LEFT JOIN (SELECT tea_prodcution_date, SUM(quantity) t2
FROM TEA_PRODUCTION
WHERE field_name like 'T2'
GROUP BY tea_prodcution_date) ON the_day = tea_prodcution_date
ORDER BY the_day
year_days是使用以下查询创建的视图。
SELECT add_months(TRUNC(sysdate - (365), 'YYYY'),to_number(to_char(sysdate,'mm'))) + (level - 1) AS the_day
FROM dual
CONNECT BY level <=
to_number(TO_CHAR(last_day(add_months(TRUNC(sysdate, 'YYYY'), 11)),
'DDD'))
当我尝试执行第一个查询以创建视图时,出现以下错误。
ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"
*Cause:
*Action:
Error at Line: 10 Column: 58
从ON the_day = tea_prodcution_date
线路发生错误。
我怎样才能纠正这个错误并创建上面的视图?