yasonisme 2009-10-23 17:58
浏览 288
已采纳

一个比较复杂的sql问题

update app_biz_acw acw set (buscode,bustype)=(
select min(his1.buscode),min(his1.bustype) from app_biz_custhisrec his1 where

(select count(*) from app_biz_custhisrec his2
where his2.connecttime>=(his1.connecttime-3/24/60)
and his2.connecttime and his2.agcid=his1.agcid
and his2.telno=his2.telno
group by his2.customerid,his2.agcid
)=0
and acw.agcid=his1.agcid
and acw.telno=his1.telno
and his1.connecttime and his1.connecttime>(acw.connecttime-5/24/60)
),acw.inputtype='2'
where acw.buscode is null

这个 buscode,bustype 更新不了. 哪位有空帮我看下
这个sql意思是 不知道怎么描述。能看懂的帮我看下吧
[b]问题补充:[/b]
不报错误.
inputtype可以update成功。
buscode,bustype不能
[b]问题补充:[/b]
这个sql效率太低了..
改了下..2个表加起来就2W的数据
2分钟还没执行完..
有什么办法提高效率呢..

  • 写回答

2条回答 默认 最新

  • CaiHuajiang 2009-10-23 18:08
    关注

    [code="sql"]update app_biz_acw acw set (buscode,bustype,inputtype)=(
    select min(his1.buscode),min(his1.bustype),'2' from app_biz_custhisrec his1 where not exists
    (select customerid from app_biz_custhisrec his2
    where his2.connecttime>=(his1.connecttime-3/24/60)
    and his2.connecttime and his2.agcid=his1.agcid
    and his2.telno=his2.telno
    )
    and acw.agcid=his1.agcid
    and acw.telno=his1.telno
    and his1.connecttime and his1.connecttime>(acw.connecttime-5/24/60)
    )
    where acw.buscode is null[/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 求一位精通京东相关开发的专家
  • ¥100 求懂行的大ge给小di解答下!
  • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
  • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
  • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多