我的代码-sql query
# coding: utf-8
# In[ ]:
WITH List AS (
SELECT e.*,f.* FROM
( SELECT DISTINCT c.lot_id, c.wafer_key,
LEFT(c.layer_id, CHARINDEX('_', c.layer_id) -1) as Layer,c.layer_id,
COUNT(0) AS defect_count,d.class_number, REPLACE(LTRIM(REPLACE(c.wafer_id, '0', ' ')), ' ', '0') as waferid
FROM [SSMC_IEDA].[dbo].[insp_wafer_summary] AS c, [SSMC_IEDA].[dbo].[insp_defect] AS d
where c.wafer_key = d.wafer_key and c.layer_id like '[CTM-M]%_ASI' and c.inspection_date BETWEEN '2018-11-01' AND '2018-11-20'
AND d.class_number in (167, 67)
GROUP BY c.lot_id,c.wafer_id,d.class_number,c.layer_id, c.wafer_key) AS e INNER JOIN
(select distinct a.recpid, a.stage, a.lotid, b.automatedrecipeid, LEFT(a.stage, CHARINDEX('_', a.stage) -1) as Stg from mes_tbl_hist AS a
INNER JOIN mes_tbl_recp AS b ON a.recpid = b.recpid WHERE a.eqpid LIKE 'AEM2%' AND a.stage NOT LIKE 'REWORK') AS f ON e.lot_id = f.lotid
AND (((e.Layer = 'CTM' OR e.Layer LIKE 'CTM%') AND (f.Stg = 'CTM' OR f.Stg LIKE 'CTM%'))
OR
(e.Layer LIKE 'M%' AND f.Stg LIKE CONCAT(substring(e.Layer, PatIndex('%[a-z]%',LOWER(e.Layer)), case PatIndex('%[a-z]%',LOWER(e.Layer)) when 0 then 2 else 1 end),'E',substring(e.Layer, PatIndex('%[0-9]%', e.Layer),case PatIndex('%[0-9]%',e.Layer) when 0 then 2 else 1 end),'%')
))
AND f.Stg NOT LIKE 'MW%'
AND f.Stg NOT LIKE 'MT%'
AND e.Layer NOT LIKE 'MT%'
AND e.Layer NOT LIKE 'MW%' )
SELECT DISTINCT List.layer_id,List.defect_count,b.eqpid, SUBSTRING(b.ParameterName, CHARINDEX('-', b.parametername) +1,1) as Chamber,
b.lotid,a.slotid,
a.waferid,
LEFT(b.ParameterName, CHARINDEX('-', b.ParameterName) -1) as Param_Name,
LEFT(c.stage, CHARINDEX('_', c.stage) -1) as Stg,
c.stage,
SUBSTRING(b.ParameterName, CHARINDEX('-', b.parametername) +3,+1) as Step,
SUBSTRING(b.ParameterName, CHARINDEX('-', b.parametername) +5, LEN( b.parametername)) as Recipie_Name,
b.parametername,
a.[data] as data1,a.finishtime,
rank() OVER (PARTITION BY a.slotid, b.eqpid,b.lotid,c.stage,List.layer_id,b.parametername ORDER BY a.finishtime) AS RNK
FROM [SSMC_RTM].[dbo].[rtm_tbl_massdata] a INNER JOIN [SSMC_RTM].[dbo].[rtm_tbl_datahist] b
ON a.[datahist_fno]=b.[fno] INNER JOIN SSMC_RTM.dbo.rtm_tbl_batchdatahist c ON b.fno = c.datahist_fno
INNER JOIN List ON List.lot_id = b.lotid AND List.waferid = a.slotid AND LEFT(c.stage, CHARINDEX('_', c.stage) -1) = List.Stg
AND SUBSTRING(b.parametername, CHARINDEX('-', b.parametername) +5, LEN( b.parametername)) = List.automatedrecipeid
WHERE b.parametername LIKE '%-4-%'
--AND b.parametername NOT LIKE '%-$'
AND b.parametername LIKE '%-%-%-%'
AND ( b.parametername LIKE 'ETCM_PHA4_A%' OR b.parametername LIKE 'ETCM_PHA4_B%'
OR b.parametername LIKE 'ETCM_PHB4_A%' OR b.parametername LIKE 'ETCM_PHB4_B%'
OR b.parametername LIKE 'ETCM_PHC4_A%' OR b.parametername LIKE 'ETCM_PHC4_B%'
OR b.parametername LIKE 'HELK_MEAN_A%' OR b.parametername LIKE 'HELK_MEAN_B%'
OR b.parametername LIKE 'LOWERCHM_PRESS_A%' OR b.parametername LIKE 'LOWERCHM_PRESS_B%'
OR b.parametername LIKE 'PBK4_A%' OR b.parametername LIKE 'PBK4_B%'
OR b.parametername LIKE 'RR23_MEAN_A%' OR b.parametername LIKE 'RR23_MEAN_B%'
OR b.parametername LIKE 'RR23_MAX._A%' OR b.parametername LIKE 'RR23_MAX._B%'
OR b.parametername LIKE 'RR13_MEAN_A%' OR b.parametername LIKE 'RR13_MEAN_B%'
OR b.parametername LIKE 'RR13_MAX._A%' OR b.parametername LIKE 'RR13_MAX._B%'
OR b.parametername LIKE 'THR3_MAX._A%' OR b.parametername LIKE 'THR3_MAX._B%'
OR b.parametername LIKE 'THR3_MAX._DIFF_A%' OR b.parametername LIKE 'THR3_MAX._DIFF_B%'
OR b.parametername LIKE 'THR3_MEAN_A%' OR b.parametername LIKE 'THR3_MEAN_B%'
OR b.parametername LIKE 'THR3_MEAN_DIFF_A%' OR b.parametername LIKE 'THR3_MEAN_DIFF_B%'
OR b.parametername LIKE 'THR3_MEAN_SLOPE_A%' OR b.parametername LIKE 'THR3_MEAN_SLOPE_B%'
-- b.parametername LIKE 'BIAS_COEF_A%' OR b.parametername LIKE 'BIAS_COEF_B%'
OR b.parametername LIKE 'CURRENT_MAX._A%' OR b.parametername LIKE 'CURRENT_MAX._B%'
OR b.parametername LIKE 'CURRENT_MAX._DIFF_A%' OR b.parametername LIKE 'CURRENT_MAX._DIFF_B%'
OR b.parametername LIKE 'CURRENT_MEAN_A%' OR b.parametername LIKE 'CURRENT_MEAN_B%'
OR b.parametername LIKE 'CURRENT_MEAN_DIFF_A%' OR b.parametername LIKE 'CURRENT_MEAN_DIFF_B%'
OR b.parametername LIKE 'DCB3_MEAN_A%' OR b.parametername LIKE 'DCB3_MEAN_B%'
--OR b.parametername LIKE 'DCB3_MEAN_DIFF_A%' OR b.parametername LIKE 'DCB3_MEAN_DIFF_B%'
OR b.parametername LIKE 'DCB3_MEAN_SLOPE_A%' OR b.parametername LIKE 'DCB3_MEAN_SLOPE_B%'
OR b.parametername LIKE 'ETCM_PHA4_DIFF_A%' OR b.parametername LIKE 'ETCM_PHA4_DIFF_B%'
OR b.parametername LIKE 'ETCM_PHB4_DIFF_A%' OR b.parametername LIKE 'ETCM_PHB4_DIFF_B%'
OR b.parametername LIKE 'ETCM_PHC4_DIFF_A%' OR b.parametername LIKE 'ETCM_PHC4_DIFF_B%'
OR b.parametername LIKE 'HECL_MAX._A%' OR b.parametername LIKE 'HECL_MAX._B%'
OR b.parametername LIKE 'HECL_MEAN_A%' OR b.parametername LIKE 'HECL_MEAN_B%'
OR b.parametername LIKE 'HECL_MEAN_DIFF_A%' OR b.parametername LIKE 'HECL_MEAN_DIFF_B%'
OR b.parametername LIKE 'HECL_MIN._A%' OR b.parametername LIKE 'HECL_MIN._B%'
OR b.parametername LIKE 'HELK_MEAN_DIFF_A%' OR b.parametername LIKE 'HELK_MEAN_DIFF_B%'
OR b.parametername LIKE 'HELK_MEAN_SLOPE_A%' OR b.parametername LIKE 'HELK_MEAN_SLOPE_B%'
OR b.parametername LIKE 'LOWERCHM_PRESS_DIFF_A%' OR b.parametername LIKE 'LOWERCHM_PRESS_DIFF_B%'
OR b.parametername LIKE 'PBK4_DIFF_A%' OR b.parametername LIKE 'PBK4_DIFF_B%'
OR b.parametername LIKE 'RF11_MAX._A%' OR b.parametername LIKE 'RF11_MAX._B%'
OR b.parametername LIKE 'RF11_MAX._DIFF_A%' OR b.parametername LIKE 'RF11_MAX._DIFF_B%'
OR b.parametername LIKE 'RF11_MEAN_A%' OR b.parametername LIKE 'RF11_MEAN_B%'
OR b.parametername LIKE 'RF21_MAX._A%' OR b.parametername LIKE 'RF21_MAX._B%'
OR b.parametername LIKE 'RF21_MEAN_A%' OR b.parametername LIKE 'RF21_MEAN_B%'
OR b.parametername LIKE 'RF21_MEAN_DIFF_A%' OR b.parametername LIKE 'RF21_MEAN_DIFF_B%'
--OR b.parametername LIKE 'RF21_MIN._A%' OR b.parametername LIKE 'RF21_MIN._B%'
OR b.parametername LIKE 'RF21_SD_A%' OR b.parametername LIKE 'RF21_SD_B%'
OR b.parametername LIKE 'RLD3_MEAN_A%' OR b.parametername LIKE 'RLD3_MEAN_B%'
OR b.parametername LIKE 'RLD3_MEAN_DIFF_A%' OR b.parametername LIKE 'RLD3_MEAN_DIFF_B%'
OR b.parametername LIKE 'RR13_MAX._A%' OR b.parametername LIKE 'RR13_MAX._B%'
OR b.parametername LIKE 'RR13_MAX._DIFF_A%' OR b.parametername LIKE 'RR13_MAX._DIFF_B%'
OR b.parametername LIKE 'RR23_MEAN_DIFF_A%' OR b.parametername LIKE 'RR23_MEAN_DIFF_B%'
OR b.parametername LIKE 'RR23_MEAN_SLOPE_A%' OR b.parametername LIKE 'RR23_MEAN_SLOPE_B%'
OR b.parametername LIKE 'RTN3_MEAN_A%' OR b.parametername LIKE 'RTN3_MEAN_B%'
OR b.parametername LIKE 'RTN3_MEAN_DIFF_A%' OR b.parametername LIKE 'RTN3_MEAN_DIFF_B%'
--OR b.parametername LIKE 'SOURCE_COEF_A%' OR b.parametername LIKE 'SOURCE_COEF_B%'
OR b.parametername LIKE 'SRTM_A%' OR b.parametername LIKE 'SRTM_B%'
OR b.parametername LIKE 'SRTM_SLOPE_A%' OR b.parametername LIKE 'SRTM_SLOPE_B%'
OR b.parametername LIKE 'TMP1_MAX._A%' OR b.parametername LIKE 'TMP1_MAX._B%'
OR b.parametername LIKE 'TMP1_MAX._DIFF_A%' OR b.parametername LIKE 'TMP1_MAX._DIFF_B%'
OR b.parametername LIKE 'TMP1_MEAN_A%' OR b.parametername LIKE 'TMP1_MEAN_B%'
--OR b.parametername LIKE 'TMP1_MEAN_DIFF_A%' OR b.parametername LIKE 'TMP1_MEAN_DIFF_B%'
OR b.parametername LIKE 'VOLT_MAX._A%' OR b.parametername LIKE 'VOLT_MAX._B%'
--OR b.parametername LIKE 'VOLT_MAX._DIFF_A%' OR b.parametername LIKE 'VOLT_MAX._DIFF_B%'
OR b.parametername LIKE 'VOLT_MEAN_A%' OR b.parametername LIKE 'VOLT_MEAN_B%'
OR b.parametername LIKE 'VOLT_MEAN_DIFF_A%' OR b.parametername LIKE 'VOLT_MEAN_DIFF_B%'
)
我的代码-sql query的更多相关文章
- NHibernate系列文章二十六:NHibernate查询之SQL Query查询(附程序下载)
摘要 NHibernate在很早的版本就提供了SQL Query(原生SQL查询),对于很复杂的查询,如果使用其他的查询方式实现比较困难的时候,一般使用SQL Query.使用SQL Query是基于 ...
- 使用JSTL的sql:query标签制作分页查询遇到NoSuchFieldError: deferredExpression
参考:http://hi.baidu.com/desyle/item/4fe650265792d7182a0f1c33 症状: 如题所述,代码如下 <sql:query var="re ...
- jstl中的sql:query标签获取的结果如何格式化输出
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- .net连接DB2的异常SQL0666 - SQL query exceeds specified time limit or storage limit.错误处理
SQL0666 - SQL query exceeds specified time limit or storage limit. 原因:查询超时 解决办法: set the DbCommand.C ...
- Freebie - Utility Form: Generate Excel Report From SQL Query In Oracle Forms 6i And 11g
Sharing a form to generate Excel file report from SQL query in Oracle Forms. This form can be used i ...
- jasper ireport create a report with parameters without sql query
I'm new in jasper ireport , and I want to know if it is possible to create a report only with static ...
- REP-20147 Cannot implement column link for this detail SQL query. Converting to group link.
注:本文为原创,作为学习交流使用,转载请标明作者及出处,作者保留追究法律责任的权力. Lumen Su lzsu1989#gmail.com (#=@) www.cnblogs.com/lzsu198 ...
- EntityFramework 学习 一 Execute Native SQL Query
SQL query for entity types: using (var ctx = new SchoolDBEntities()) { var studentList = ctx.Student ...
- Entity Framework Tutorial Basics(39):Raw SQL Query
Execute Native SQL Query You can execute native raw SQL query against the database using DBContext. ...
随机推荐
- CSS3绘制特殊图形
- WPF listbox实现多列显示数据
一.每行显示固定列数 <ListBox ItemsSource="{Binding DataList}" Style="{DynamicResource ListB ...
- MySQL常用的锁机制 ----------顾名思义
悲观锁与乐观锁: 悲观锁:顾名思义,就是很悲观,每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这个数据就会block直到它拿到锁.传统的关系型数据库里边就用到了很多这 ...
- 五、Vi和Vim编辑器
1. Vim编辑器: 在Linux下一般使用vi编辑器来编辑文件.vi既可以查看文件也可以编辑文件.三种模式: 命令行.插入.底行模式 切换到命令行模式:按Esc键: 切换到插入模式:按 i .o.a ...
- grid-layout
<!-- 创建三个网格布局--> .wrapper { <!--创建一个网格布局 --> display: grid; <!--创建3列 且每列都等距 --> gr ...
- firefox 屏蔽Backspace按键的后退功能
直接上图
- Linux系统调用列表(转)
以下是Linux系统调用的一个列表,包含了大部分常用系统调用和由系统调用派生出的的函数.这可能是你在互联网上所能看到的唯一一篇中文注释的Linux系统调用列表,即使是简单的字母序英文列表,能做到这么完 ...
- app模块设计
至于app模块设计,要坚持三个原则: 1.放羊,让用户决定模块间的组合与穿插. 2.滥竽充数,对于用户不希望的模块,可以悄悄植入以实现产品目标. 3.照葫芦画瓢,遵守用户在其它APP上的既有习惯,组合 ...
- hive表分区操作
1.修复表分区命令 msck repair table table_name; 2.添加表分区操作 alter table table_name add partition(month_id='201 ...
- Curve 曲线 工具
最近研究了曲线绘制的工具,主要是2D方程的绘制.综合了许多工具,完成了一下两个脚本. 绘制的工具: using UnityEngine; using System.Collections; using ...