zoukankan      html  css  js  c++  java
  • sqlserver 一段代码带来的思维小启发

    /* 销售单编号不在核销_销售的自动核销里面,且部门号=传入值,客户编号=传入值,*/
    select x.fph, x.ccode, x.ddate, x.invoicetype, x.itotalbilling, x.csalespersoname,SUM(isnull(hx.bchxje,0)) as yhxje,hx.bchxje,'正常运作' as tclx 
    from dbo.ww_cw_xsfp as x 
    left join ww_cw_hxd_xsfp as hx on ccode = hx.fpdjh 
    where cclientnum ='3' and deptnum ='010101' 
    	and ccode not in (select fpdjh from dbo.ww_cw_hxd_xsfp where bchxje = fpze) 
    group by x.ccode,x.fph,x.ddate, x.invoicetype, x.itotalbilling, x.csalespersoname,yhxje,hx.bchxje,tclx,hx.fpze,x.dcreatetime
    order by x.dcreatetime 
    
    --打脸,如下
    SELECT * FROM zsk_cwgl_xsfp 
    left join (select fpcode,isnull(sum(ihxje),0) as iyhxje from zsk_cwgl_hxd_mx group by fpcode) as hxhj on zsk_cwgl_xsfp.ccode=hxhj.fpcode 
    where (ikpze <>hxhj.iyhxje  or hxhj.iyhxje is null ) 
    and cbmbh='"+rdm.get("cbmbh")+"' 
    and ckhbh='"+rdm.get("ckhbh")+"' 
    and czzbh='"+rdm.get("czzbh")+"'"
    总结:当需要再链接一个表时,把主键和需要的字段从表里搜出来作为另一个数据集再链接
    

      

  • 相关阅读:
    Ext简单demo示例
    git命令行操作
    js继承方式
    一次活动总结
    h5自定义audio(问题及解决)
    JavaScript标准参考教材(alpha)--笔记
    css揭秘--笔记(未完)
    css权威指南--笔记
    h5上传图片及预览
    gulp入门小记
  • 原文地址:https://www.cnblogs.com/ziyanxiaozhu/p/9916422.html
Copyright © 2011-2022 走看看