我在update子句中遇到一个问题。我正在努力做到以下几点:
update AM1 from DB.AM_7541 AM1,
(sel distinct TRIM(SB.LCDBDN) NEID, trim( leading '0' from sb.lcdmno) LCDMNO,
AM.Netw_equip
from
DB1.PLTL SB
inner join DB.AM_7541 AM
on trim( leading '0' from sb.lcdmno)=AM.accs_meth_num
where SB.LOAD_DATE in ( sel max(load_date),lcdmno,lcdbdn from DB1.PLTL where lcdmno not like ' ' and lcdmno is not null group by lcdmno, lcdbdn)
and SB.LCDBDN not like ''
) der
set Netw_equip=der.NEID
where AM1.accs_meth_num=der.lcdmno
我必须将最大(load_dt)分组放在lcdmno和lcdbdn上。 我在select子句中遇到了太多表达式的错误。
你可以帮我解决这个问题。
检查了重复:
sel NEID, LCDMNO, COUNT(*) from
(
sel distinct TRIM(SB.LCDBDN) NEID, trim( leading '0' from sb.lcdmno) LCDMNO,
AM.Netw_equip
from
DB1.PLTL SB
inner join DB.AM_7541 AM
on trim( leading '0' from sb.lcdmno)=AM.accs_meth_num
where SB.LOAD_DATE in ( sel max(load_date),lcdmno,lcdbdn from DB1.PLTL where lcdmno not like ' ' and lcdmno is not null group by lcdmno, lcdbdn)
and SB.LCDBDN not like '')
group by 1,2
having count(*)>1
--- 0行 谢谢, 阿米特
答案 0 :(得分:2)
错误是自我解释的,您在子查询中返回三列但仅与单行进行比较。
使用Correlated Subquery或多列子查询重写:
cancel
顺便说一句,应用一些格式确实简化了阅读/理解查询。