zoukankan      html  css  js  c++  java
  • 多个数据表联表查询

    根据生产id查询出当天的生产记录

    select  a.RobotNo as 机台,a.ProductCode as 生产CODE, a.ProducePlan as  计划数,b.ProductionCount_Total as 生产数,
    a.Productivity as 生产性,d.StateText as 状态内容,c.BadnessCount as 不良数,a.Operator as 作业者,
    a.Technician as 技术担当,a.Approver as 确认,a.Confirmor as 承认
    from (select * from TouchDisplay.dbo.Table_ProductionMain where ProduceDate=CONVERT(varchar(100), GETDATE(), 23)) as a left join
    TouchDisplay.dbo.Table_OutputReport as b on a.Tid=b.ProduceId left join 
    (select ProduceId,SUM(BadnessCount) as BadnessCount from TouchDisplay.dbo.Table_BadnessReport group by ProduceId) as c on a.Tid=c.ProduceId left join
    (select * from (select sr.Tid,sr.ProduceId,StateText from TouchDisplay.dbo.Table_StateInfo,TouchDisplay.dbo.Table_StateReport as sr where sr.StateNo=TouchDisplay.dbo.Table_StateInfo.StateNo ) as s where Tid=(select MAX(Tid) from (select sr.Tid,sr.ProduceId,StateText from TouchDisplay.dbo.Table_StateInfo,TouchDisplay.dbo.Table_StateReport as sr where sr.StateNo=TouchDisplay.dbo.Table_StateInfo.StateNo ) as ss where ss.ProduceId=s.ProduceId  )) as d
    on a.Tid=d.ProduceId
  • 相关阅读:
    ES6对象的扩展
    ES6函数的扩展
    ES6新增变量
    ES6框架的搭建
    自适应布局 左右结构、上下结构
    iframe 子页面改变父页面样式
    检测终端类型
    $.grep()
    点击元素内部不隐藏,点击元素外部元素隐藏
    angular表单验证
  • 原文地址:https://www.cnblogs.com/kellen451/p/6720289.html
Copyright © 2011-2022 走看看