请教sql问题:ORA-00918: 未明确定义列

DengTin 2012-03-05 02:35:09
以下是sql内容,不知道哪儿错了。
select t.meta_task_result_id,
st.scheduler_name,
tt.task_name,
rt.resource_name,
upper(mtt.app_name),
mtt.tem_name,
mtt.tem_name,
t.instance,
mtt.descp,
case
when length(t.value) > 20 then
substr(t.value, 1, 20) || '...'
else
t.value
end,
mtt.UNIT,
T.META_TASK_STATE,
t.alarm,
T.ADVICE,
to_char(get_date_from_millisecond(t.time), 'YYYY-mm-dd HH24:mi:ss'),
t.alarm_info,
T.OPINION,
T.VALUE_CHECK,
t.meta_task_id,
st.minutes || ';' || st.hours as cyc,
mtt.value_type,
st.scheduler_id,
mtt.meta_task_id
from day_meta_task_result t,
scheduler_table st,
task_table tt,
meta_task_table mtt,
(select r1.resource_id,
decode(r2.value, null, r1.resource_name, r2.value) resource_name
from resource_table r1
left join resource_info_table r2
on (r1.resource_id = r2.resource_id and r2.ukey = 'test_key_1')) rt
where t.scheduler_id = '8aca818c312760f001312d18fdea0239'
and st.scheduler_id = '8aca818c312760f001312d18fdea0239'
and t.scheduler_id = st.scheduler_id
and st.task_id = tt.task_id
and t.meta_task_id = mtt.meta_task_id
and mtt.resource_id = rt.resource_id

and t.META_TASK_STATE = 0
and t.time = 1330880340117
order by rt.resource_name, mtt.tem_name
...全文
654 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
DengTin 2012-03-05
  • 打赏
  • 举报
回复
已经解决了,问题和sql本身无关,多谢楼上各位的帮忙
DengTin 2012-03-05
  • 打赏
  • 举报
回复
还是不行[Quote=引用 4 楼 mailking 的回复:]

case
when length(t.value) > 20 then
substr(t.value, 1, 20) || '...'
else
t.value
end

加括号 并且给个列名
(case
when length(t.value) > 20 then
substr(t.value, 1, 20) || '...'
else
……
[/Quote]
我心飞翔 2012-03-05
  • 打赏
  • 举报
回复
原因很简单,就查你要查询的列,同时出现在2个或2个以上的表中,必须明确指定是哪个表的中列。
mailking 2012-03-05
  • 打赏
  • 举报
回复
case
when length(t.value) > 20 then
substr(t.value, 1, 20) || '...'
else
t.value
end

加括号 并且给个列名
(case
when length(t.value) > 20 then
substr(t.value, 1, 20) || '...'
else
t.value
end) casevalue
秋雨飘落 2012-03-05
  • 打赏
  • 举报
回复
未明确定义列,肯定有别名的问题啊,或者相同的列名导致
DengTin 2012-03-05
  • 打赏
  • 举报
回复
谢谢回答,但不是这个问题[Quote=引用 1 楼 siyuan2006 的回复:]

mtt.tem_name select里面有俩 是这个
[/Quote]
siyuan2006 2012-03-05
  • 打赏
  • 举报
回复
mtt.tem_name select里面有俩 是这个

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧