主要是andwhere的区别:
 
原Sql:
select a.ID as reqid,(select top  Convert(nvarchar(),jhdatez,) from CS_OrderPro
where Codeno=a.InvNo and iProductId =a.iProductId)as 'jhdate',
(select top Deptname from UserInfo left join Department on UserInfo.deptid=Department.Deptid where UserInfo.userid=AuditUserId) as deptname,
(select isnull(SUM(iNum),) from CS_OrderPro where CS_OrderPro.zid=a.ID and CS_OrderPro.codeno=a.Invno) as cgnum,
(select top InvNO from CS_OrderPro where CS_OrderPro.zid=a.ID and CS_OrderPro.codeno=a.Invno) as cginvno,
(select isnull(SUM(CS_InvRecBill.iNum),) from CS_InvRecBill
left join CS_OrderPro on CS_InvRecBill.zid=CS_OrderPro.ID
where CS_OrderPro.zid=a.ID and CS_OrderPro.codeno=a.Invno) as rknum,*,
isnull((select sum(pronum) from cs_stock where proid=a.iproductid),) as kcnum,
comoditiestype from CS_OrderRequise a left join CS_OrderRequiseList c on c.OutCode=a.InvNO
left join B_Products b on b.id=a.iProductID
left join ComoditiesType on ComoditiesType.typeid=b.typeid where = and c.isend= and ComoditiesType.typeid<>336

左连接查询后,最后的where语句过滤了本该显示的数据。

修改过的Sql:

select a.ID as reqid,(select top  Convert(nvarchar(),jhdatez,) from CS_OrderPro
where Codeno=a.InvNo and iProductId =a.iProductId)as 'jhdate',
(select top Deptname from UserInfo left join Department on UserInfo.deptid=Department.Deptid where UserInfo.userid=AuditUserId) as deptname,
(select isnull(SUM(iNum),) from CS_OrderPro where CS_OrderPro.zid=a.ID and CS_OrderPro.codeno=a.Invno) as cgnum,
(select top InvNO from CS_OrderPro where CS_OrderPro.zid=a.ID and CS_OrderPro.codeno=a.Invno) as cginvno,
(select isnull(SUM(CS_InvRecBill.iNum),) from CS_InvRecBill
left join CS_OrderPro on CS_InvRecBill.zid=CS_OrderPro.ID
where CS_OrderPro.zid=a.ID and CS_OrderPro.codeno=a.Invno) as rknum,*,
isnull((select sum(pronum) from cs_stock where proid=a.iproductid),) as kcnum,
comoditiestype from CS_OrderRequise a left join CS_OrderRequiseList c on c.OutCode=a.InvNO
left join B_Products b on b.id=a.iProductID
left join ComoditiesType on ComoditiesType.typeid=b.typeid AND ComoditiesType.typeid<>336 where = and c.isend=

left join 左边有数据,右边无数据的更多相关文章

  1. flink-----实时项目---day06-------1. 获取窗口迟到的数据 2.双流join(inner join和left join(有点小问题)) 3 订单Join案例(订单数据接入到kafka,订单数据的join实现,订单数据和迟到数据join的实现)

    1. 获取窗口迟到的数据 主要流程就是给迟到的数据打上标签,然后使用相应窗口流的实例调用sideOutputLateData(lateDataTag),从而获得窗口迟到的数据,进而进行相关的计算,具体 ...

  2. SQL server 存储过程 C#调用Windows CMD命令并返回输出结果 Mysql删除重复数据保留最小的id C# 取字符串中间文本 取字符串左边 取字符串右边 C# JSON格式数据高级用法

    create proc insertLog@Title nvarchar(50),@Contents nvarchar(max),@UserId int,@CreateTime datetimeasi ...

  3. MySQL时间段查询,无数据补0

    上一节提到分时间段统计,可是无数据的时候不显示,而此时我们需要让他显示0. 首先我们需要建一个时间表. CREATE TABLE `my_date` ( `date` date NOT NULL, P ...

  4. Repeater为空时显示“暂无数据”,很方便实用方法

    Repeater为空时显示“暂无数据”,很方便实用方法 <FooterTemplate>   <asp:Label ID="lblEmptyZP" Text=&q ...

  5. 关于echart没有数据显示暂无数据

    对于echart当没有数据的时候怎么显示, 首先,如果你的series的值为空值的话,曲线将是一片空白,什么都不会有,所以在这里就要进行一个判断,如果没有值的话,人为的添加一个键 if(Object. ...

  6. rancher导入k8s集群后添加监控无数据

    1.日志报错 rancher导入k8s集群后添加监控无数据,rancher日志报错: k8s.io/kube-state-metrics/pkg/collectors/builder.go:: Fai ...

  7. sql 数据处理时join字段慎重选择--避免出现double数据!

    前几天做BI Tabular表格模型的时候,数据中心核对数据发现模型展现数据比实际数据要多,经过核查之后,发现原来我是一个不经意,在做数据选取的时候,inner join的字段CITY_NAME_CN ...

  8. C/C++ socket编程教程之九:TCP的粘包问题以及数据的无边界性

    C/C++ socket编程教程之九:TCP的粘包问题以及数据的无边界性 上节我们讲到了socket缓冲区和数据的传递过程,可以看到数据的接收和发送是无关的,read()/recv() 函数不管数据发 ...

  9. 【Transact-SQL】SQL Server自动把left join自动转化为inner join、以及关联时的数据重复问题

    原文:[Transact-SQL]SQL Server自动把left join自动转化为inner join.以及关联时的数据重复问题 1.SQL Server自动把left join自动转化为inn ...

随机推荐

  1. Mongoose 数据校验

    什么是mongoose数据校验 用户通过mongoose给mongodb数据库增加数据的时候,对数据的合法性进行的验证 mongoose里面定义Schema:字段类型,修饰符.默认参数 .数据校验都是 ...

  2. player: 初始化分析

    //1. //cocos 程序开始运行时执行的函数 bool AppDelegate::applicationDidFinishLaunching() { // initialize director ...

  3. Fluent导出残差总结

    在使用Fluent进行求解的时候,有时候我们需要将求解的残差提取出来,进行后续的处理,我们可以采用下面的方法将Fluent求解残差输出.下面我们用一个简单的二维算例来说明(算例来源于:https:// ...

  4. Johnson算法:多源最短路算法

    Johnson算法 请不要轻易点击标题 一个可以在有负边的图上使用的多源最短路算法 时间复杂度\(O(n \cdot m \cdot log \ m+n \cdot m)\) 空间复杂度\(O(n+m ...

  5. php curl 转为 x-www-form-urlencoded 方式

    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); fr ...

  6. SpringCloud Gateway跨域配置

    Springboot版本:2.1.8.RELEASE SpringCloud版本:Greenwich.SR2 yml配置: spring: cloud: gateway: globalcors: co ...

  7. sublime px转rem的方法【亲测有效】

    在开发手机网站的时候,我们经常会用到rem来作为单位,但是手动转rem太麻烦了,那么怎么办呢?sublime安装cssrem来进行快捷操作. 安装过程: 第一步:去git上克隆 https://git ...

  8. Nginx的configure脚本支持选项整理

    在不同版本间,选项可能会有些许变化,请总是使用./configure –help命令来检查当前的选项列表. --prefix=<PATH> #Nginx安装路径.如果没有指定,默认为 /u ...

  9. python初级(302) 7 列表(二)冒泡排序

    一.复习: 1.如何创建一个空列表,如何创建一个有数据的列表 2.列表可以包含的内容 3.从列表中获取元素和修改元素的方法 4.列表的分片 5.增加元素和删除元素 6.选择排序的算法: 一堆数据,每次 ...

  10. C# HashSet集合类型使用介绍

    1.HashSet集合 使用HashSet可以提高集合的运算.使用HashSet集合不自带排序方法,如果需要排序的需求可以参考使用List<T>集合配合Sort方法. HashSet的优势 ...