gjfvip123 2017-04-19 18:19 采纳率: 0%
浏览 1073
已采纳

请问大神这句sql语句是什么意思

con.execute "update Temp_Report"&userid&" set datal = total, h = n from (select count(*) n, sum(isnull(int2,0)) total, w from Temp_Report"&userid&" group by w) as a where Temp_Report"&userid&".w = a.w"

其中不明白的地方是:
from (select count(*) n, sum(isnull(int2,0)) total //from 后边不是应该接的是从哪个表吗? 但这个后边应该表,而是列吧?另外,n , total 是将count 和 sum(isnull(int2,0))值保持到 n 和total吗?

  • 写回答

2条回答 默认 最新

  • zhangsheng_1992 2017-04-19 18:25
    关注

    1.首先子查询select count(*) n, sum(isnull(int2,0)) total, w from Temp_Report"&userid&" group by w 查询出来的相当于一张临时表

    2.值是保持的 只要字段名字对应 所以他在子查询里面进程了 as操作 count 和sum的记过分别保存在 n 和total中 as可以省略 这么写你应该能容易理解些 elect count(*) as n, sum(isnull(int2,0)) as total, w from Temp_Report"&userid&" group by w

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部