你好再次非常慷慨的人。我想弄清楚如何获得组内的最新记录?图片附在下面:
根据上面的结果集,晶圆编号 7 和 11 有两次插入。我的问题是,在这样的情况下,某个晶圆编号有多个插入,我应该只显示最近的两次插入. 如何在查询中执行此操作?这是我到目前为止的查询:
SELECT wipdata.wafernumber
,wipdata.specname
,wipdata.insertionnumber
,wipdata.insertionreasonname
,wipdata."Total Good DPW"
,wipdata."Accept Bins B1"
,wipdata."Accept Bins B2"
,wipdata."Accept Bins B3"
,wipdata."Accept Bins B4"
,wipdata."Reject Continuity"
,wipdata."Total Rejects"
,wipdata."Probe Mark Insp"
,wipdata."Ink Dot Insp"
,wipdata."Visual Insp"
,wipdata."Comments"
,wipdata."Operator"
,wipdata."Inspector"
,wipdata."Engineer"
,wipdata."Supervisor"
--,mh.wipdatavalue "MH"
,wipdata."TPE Disposition"
,wipdata."Supervisor Disposition"
,wipdata."Check Code"
,wipdata."Laser power Setup"
,wipdata."Laser Trim Energy"
,wipdata."Duan Ink"
,wipdata."Inked Edges"
,wipdata."100% Visual Qty"
,wipdata."New Total GDPW"
,wipdata."Yield"
,wipdata.txndate
,DECODE(SUBSTR(wipdata.specname,0,4),'5267','12345', wipdata.equipmentid) equipmentid
FROM
(
SELECT c.containername
,wl.specid
,wl.specname
,wl.wiptrackinggroupkeyid
,wl.wiplothistoryid
,wld.wiplotdetailshistoryid
,wldd.wiplotdetailsdatahistoryid
,wldw.wafernumber
,wldd.wipdatanamename
,TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0)) AS "Total Good DPW"
,ab1.wipdatavalue "Accept Bins B1"
,ab2.wipdatavalue "Accept Bins B2"
,ab3.wipdatavalue "Accept Bins B3"
,ab4.wipdatavalue "Accept Bins B4"
,rc.wipdatavalue "Reject Continuity"
,wldw.processwaferrejectsqty "Total Rejects"
,pmi.wipdatavalue "Probe Mark Insp"
,idi.wipdatavalue "Ink Dot Insp"
,vip.wipdatavalue "Visual Insp"
,comments.wipdatavalue "Comments"
,oper.wipdatavalue "Operator"
,insp.wipdatavalue "Inspector"
,engr.wipdatavalue "Engineer"
,supv.wipdatavalue "Supervisor"
--,mh.wipdatavalue "MH"
,tpeDispo.wipdatavalue "TPE Disposition"
,supvDispo.wipdatavalue "Supervisor Disposition"
,cc.Wipdatavalue "Check Code"
,lps.Wipdatavalue "Laser power Setup"
,lte.Wipdatavalue "Laser Trim Energy"
,di.Wipdatavalue "Duan Ink"
,ie.Wipdatavalue "Inked Edges"
,vq.Wipdatavalue "100% Visual Qty"
,ntg.Wipdatavalue "New Total GDPW"
, CASE WHEN (TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0))) = 0 THEN NULL
ELSE ROUND((TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0)) )
/(TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0)) +
wldw.processwaferrejectsqty - TO_NUMBER(NVL(rc.wipdatavalue,0))) * 100, 2) END AS "Yield"
,wldd.txntimestamp txndate
,wldw.wafersequence
,wldw.equipmentid
,wl.insertionnumber
,wl.insertionreasonname
FROM a_wiplothistory wl
JOIN Container C ON wl.containerid = c.containerid
JOIN a_wiplotdetailshistory wld ON wl.wiplothistoryid = wld.wiplothistoryid
JOIN a_wiplotdetailsdatahistory wldd ON wld.wiplotdetailshistoryid = wldd.wiplotdetailshistoryid
LEFT JOIN a_wiplotdetailswafershistory wldw ON wldw.wiplotdetailshistoryid = wld.wiplotdetailshistoryid AND wldd.waferscribenumber = wldw.waferscribenumber
LEFT JOIN a_wiplotdetailsdatahistory ab1 ON wld.wiplotdetailshistoryid = ab1.wiplotdetailshistoryid AND ab1.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab1.wipdatanamename)) = 'WS_ACCEPT BIN1'
LEFT JOIN a_wiplotdetailsdatahistory ab2 ON wld.wiplotdetailshistoryid = ab2.wiplotdetailshistoryid AND ab2.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab2.wipdatanamename)) = 'WS_ACCEPT BIN2'
LEFT JOIN a_wiplotdetailsdatahistory ab3 ON wld.wiplotdetailshistoryid = ab3.wiplotdetailshistoryid AND ab3.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab3.wipdatanamename)) LIKE 'WS_%ACCEPT BIN3'
LEFT JOIN a_wiplotdetailsdatahistory ab4 ON wld.wiplotdetailshistoryid = ab4.wiplotdetailshistoryid AND ab4.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab4.wipdatanamename)) LIKE 'WS_%ACCEPT BIN4'
LEFT JOIN a_wiplotdetailsdatahistory tr ON wld.wiplotdetailshistoryid = tr.wiplotdetailshistoryid AND tr.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(tr.wipdatanamename)) = 'WS_TOTAL REJECTS'
LEFT JOIN a_wiplotdetailsdatahistory rc ON wld.wiplotdetailshistoryid = rc.wiplotdetailshistoryid AND rc.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(rc.wipdatanamename)) = 'WS_REJECT CONTINUITY'
LEFT JOIN a_wiplotdetailsdatahistory pmi ON wld.wiplotdetailshistoryid = pmi.wiplotdetailshistoryid AND pmi.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(pmi.wipdatanamename)) LIKE 'WS_PM/LASER%'
LEFT JOIN a_wiplotdetailsdatahistory idi ON wld.wiplotdetailshistoryid = idi.wiplotdetailshistoryid AND idi.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(idi.wipdatanamename)) LIKE 'WS_INK%DOT%'
LEFT JOIN a_wiplotdetailsdatahistory vip ON wld.wiplotdetailshistoryid = vip.wiplotdetailshistoryid AND vip.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(vip.wipdatanamename)) LIKE 'WS_VISUAL%'
LEFT JOIN a_wiplotdetailsdatahistory comments ON wld.wiplotdetailshistoryid = comments.wiplotdetailshistoryid AND comments.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(comments.wipdatanamename)) = 'WS_COMMENTS'
LEFT JOIN a_wiplotdetailsdatahistory oper ON wld.wiplotdetailshistoryid = oper.wiplotdetailshistoryid AND oper.waferscribenumber = wldd.waferscribenumber AND (TRIM(UPPER(oper.wipdatanamename)) = 'WS_OPERATOR' OR TRIM(UPPER(oper.wipdatanamename)) = 'WS_OPERATOR_GRID')
LEFT JOIN a_wiplotdetailsdatahistory insp ON wld.wiplotdetailshistoryid = insp.wiplotdetailshistoryid AND insp.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(insp.wipdatanamename)) = 'WS_INSPECTOR'
LEFT JOIN a_wiplotdetailsdatahistory engr ON wld.wiplotdetailshistoryid = engr.wiplotdetailshistoryid AND engr.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(engr.wipdatanamename)) LIKE 'WS_%ENGINEER'
LEFT JOIN a_wiplotdetailsdatahistory supv ON wld.wiplotdetailshistoryid = supv.wiplotdetailshistoryid AND supv.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(supv.wipdatanamename)) = 'WS_SUPERVISOR'
LEFT JOIN a_wiplotdetailsdatahistory tpeDispo ON wld.wiplotdetailshistoryid = tpeDispo.wiplotdetailshistoryid AND tpeDispo.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(tpeDispo.wipdatanamename)) = 'WS_TPE DISPOSITION'
LEFT JOIN a_wiplotdetailsdatahistory supvDispo ON wld.wiplotdetailshistoryid = supvDispo.wiplotdetailshistoryid AND supvDispo.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(supvDispo.wipdatanamename)) = 'WS_SUPV DISPOSITION'
--LEFT JOIN a_wiplotdetailsdatahistory mh ON wld.wiplotdetailshistoryid = mh.wiplotdetailshistoryid AND mh.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(mh.wipdatanamename)) = 'WS_MH'
LEFT JOIN a_wiplotdetailsdatahistory cc ON wld.wiplotdetailshistoryid = cc.wiplotdetailshistoryid AND cc.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(cc.wipdatanamename)) = 'WS_CHECK CODE'
LEFT JOIN a_wiplotdetailsdatahistory lps ON wld.wiplotdetailshistoryid = lps.wiplotdetailshistoryid AND lps.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(lps.wipdatanamename)) = 'WS_LASER POWER SETUP(P/F)'
LEFT JOIN a_wiplotdetailsdatahistory lte ON wld.wiplotdetailshistoryid = lte.wiplotdetailshistoryid AND lte.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(lte.wipdatanamename)) LIKE 'WS_LASER TRIM ENERGY%'
LEFT JOIN a_wiplotdetailsdatahistory di ON wld.wiplotdetailshistoryid = di.wiplotdetailshistoryid AND di.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(di.wipdatanamename)) = 'WS_DUAL INK (Y/N)'
LEFT JOIN a_wiplotdetailsdatahistory ie ON wld.wiplotdetailshistoryid = ie.wiplotdetailshistoryid AND ie.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ie.wipdatanamename)) = 'WS_INKED EDGES (Y/N)'
LEFT JOIN a_wiplotdetailsdatahistory vq ON wld.wiplotdetailshistoryid = vq.wiplotdetailshistoryid AND vq.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(vq.wipdatanamename)) LIKE 'WS_100%VISUAL%QTY'
LEFT JOIN a_wiplotdetailsdatahistory ntg ON wld.wiplotdetailshistoryid = ntg.wiplotdetailshistoryid AND ntg.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ntg.wipdatanamename)) = 'WS_NEW TOTAL GDPW'
WHERE c.containername =:lotID AND (TRIM(UPPER(wldd.wipdatanamename)) = 'WS_ACCEPT BIN1' OR ( (TRIM(UPPER(wldd.wipdatanamename)) LIKE 'WS_LASER TRIM ENERGY%' AND wl.specname LIKE '5207_%' )
OR (TRIM(UPPER(wldd.wipdatanamename)) LIKE 'WS_100%VISUAL%QTY' AND SUBSTR(wl.specname,0,4) = '5267' ) ) )
UNION ALL
SELECT c.containername
,wl.specid
,wl.specname
,wl.wiptrackinggroupkeyid
,wl.wiplotid
,wld.wiplotdetailsid
,wldd.wiplotdetailsdataid
,wldw.wafernumber
,wldd.wipdatanamename
,TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0)) AS "Total Good DPW"
,ab1.wipdatavalue "Accept Bins B1"
,ab2.wipdatavalue "Accept Bins B2"
,ab3.wipdatavalue "Accept Bins B3"
,ab4.wipdatavalue "Accept Bins B4"
,rc.wipdatavalue "Reject Continuity"
,wldw.processwaferrejectsqty "Total Rejects"
,pmi.wipdatavalue "Probe Mark Insp"
,idi.wipdatavalue "Ink Dot Insp"
,vip.wipdatavalue "Visual Insp"
,comments.wipdatavalue "Comments"
,oper.wipdatavalue "Operator"
,insp.wipdatavalue "Inspector"
,engr.wipdatavalue "Engineer"
,supv.wipdatavalue "Supervisor"
--,mh.wipdatavalue "MH"
,tpeDispo.wipdatavalue "TPE Disposition"
,supvDispo.wipdatavalue "Supervisor Disposition"
,cc.Wipdatavalue "Check Code"
,lps.Wipdatavalue "Laser power Setup"
,lte.Wipdatavalue "Laser Trim Energy"
,di.Wipdatavalue "Duan Ink"
,ie.Wipdatavalue "Inked Edges"
,vq.Wipdatavalue "100% Visual Qty"
,ntg.Wipdatavalue "New Total GDPW"
, CASE WHEN (TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0))) = 0 THEN NULL
ELSE ROUND((TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0)) )
/(TO_NUMBER(NVL(ab1.wipdatavalue,0)) + TO_NUMBER(NVL(ab2.wipdatavalue,0)) + TO_NUMBER(NVL(ab3.wipdatavalue,0)) + TO_NUMBER(NVL(ab4.wipdatavalue,0)) +
TO_NUMBER(NVL(wldw.processwaferrejectsqty,0)) - TO_NUMBER(NVL(rc.wipdatavalue,0))) * 100, 2) END AS "Yield"
,wldd.txntimestamp txndate
,wldw.wafersequence
,wldw.equipmentid
,wl.insertionnumber
,wl.insertionreasonname
FROM a_wiplot wl
JOIN Container C ON wl.containerid = c.containerid
JOIN a_wiplotdetails wld ON wl.wiplotid = wld.wiplotid
JOIN a_wiplotdetailsdata wldd ON wld.wiplotdetailsid = wldd.wiplotdetailsid
LEFT JOIN a_wiplotdetailswafers wldw ON wldw.wiplotdetailsid = wld.wiplotdetailsid AND wldd.waferscribenumber = wldw.waferscribenumber
LEFT JOIN a_wiplotdetailsdata ab1 ON wld.wiplotdetailsid = ab1.wiplotdetailsid AND ab1.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab1.wipdatanamename)) = 'WS_ACCEPT BIN1'
LEFT JOIN a_wiplotdetailsdata ab2 ON wld.wiplotdetailsid = ab2.wiplotdetailsid AND ab2.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab2.wipdatanamename)) = 'WS_ACCEPT BIN2'
LEFT JOIN a_wiplotdetailsdata ab3 ON wld.wiplotdetailsid = ab3.wiplotdetailsid AND ab3.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab3.wipdatanamename)) LIKE 'WS_%ACCEPT BIN3'
LEFT JOIN a_wiplotdetailsdata ab4 ON wld.wiplotdetailsid = ab4.wiplotdetailsid AND ab4.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ab4.wipdatanamename)) LIKE 'WS_%ACCEPT BIN4'
LEFT JOIN a_wiplotdetailsdata tr ON wld.wiplotdetailsid = tr.wiplotdetailsid AND tr.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(tr.wipdatanamename)) = 'WS_TOTAL REJECTS'
LEFT JOIN a_wiplotdetailsdata rc ON wld.wiplotdetailsid = rc.wiplotdetailsid AND rc.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(rc.wipdatanamename)) = 'WS_REJECT CONTINUITY'
LEFT JOIN a_wiplotdetailsdata pmi ON wld.wiplotdetailsid = pmi.wiplotdetailsid AND pmi.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(pmi.wipdatanamename)) LIKE 'WS_PM/LASER%'
LEFT JOIN a_wiplotdetailsdata idi ON wld.wiplotdetailsid = idi.wiplotdetailsid AND idi.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(idi.wipdatanamename)) LIKE 'WS_INK%DOT%'
LEFT JOIN a_wiplotdetailsdata vip ON wld.wiplotdetailsid = vip.wiplotdetailsid AND vip.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(vip.wipdatanamename)) LIKE 'WS_VISUAL%'
LEFT JOIN a_wiplotdetailsdata comments ON wld.wiplotdetailsid = comments.wiplotdetailsid AND comments.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(comments.wipdatanamename)) = 'WS_COMMENTS'
LEFT JOIN a_wiplotdetailsdata oper ON wld.wiplotdetailsid = oper.wiplotdetailsid AND oper.waferscribenumber = wldd.waferscribenumber AND (TRIM(UPPER(oper.wipdatanamename)) = 'WS_OPERATOR' OR TRIM(UPPER(oper.wipdatanamename)) = 'WS_OPERATOR_GRID')
LEFT JOIN a_wiplotdetailsdata insp ON wld.wiplotdetailsid = insp.wiplotdetailsid AND insp.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(insp.wipdatanamename)) = 'WS_INSPECTOR'
LEFT JOIN a_wiplotdetailsdata engr ON wld.wiplotdetailsid = engr.wiplotdetailsid AND engr.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(engr.wipdatanamename)) LIKE 'WS_%ENGINEER'
LEFT JOIN a_wiplotdetailsdata supv ON wld.wiplotdetailsid = supv.wiplotdetailsid AND supv.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(supv.wipdatanamename)) = 'WS_SUPERVISOR'
LEFT JOIN a_wiplotdetailsdata tpeDispo ON wld.wiplotdetailsid = tpeDispo.wiplotdetailsid AND tpeDispo.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(tpeDispo.wipdatanamename)) = 'WS_TPE DISPOSITION'
LEFT JOIN a_wiplotdetailsdata supvDispo ON wld.wiplotdetailsid = supvDispo.wiplotdetailsid AND supvDispo.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(supvDispo.wipdatanamename)) = 'WS_SUPV DISPOSITION'
--LEFT JOIN a_wiplotdetailsdata mh ON wld.wiplotdetailsid = mh.wiplotdetailsid AND mh.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(mh.wipdatanamename)) = 'WS_MH'
LEFT JOIN a_wiplotdetailsdata cc ON wld.wiplotdetailsid = cc.wiplotdetailsid AND cc.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(cc.wipdatanamename)) = 'WS_CHECK CODE'
LEFT JOIN a_wiplotdetailsdata lps ON wld.wiplotdetailsid = lps.wiplotdetailsid AND lps.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(lps.wipdatanamename)) = 'WS_LASER POWER SETUP(P/F)'
LEFT JOIN a_wiplotdetailsdata lte ON wld.wiplotdetailsid = lte.wiplotdetailsid AND lte.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(lte.wipdatanamename)) LIKE 'WS_LASER TRIM ENERGY%'
LEFT JOIN a_wiplotdetailsdata di ON wld.wiplotdetailsid = di.wiplotdetailsid AND di.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(di.wipdatanamename)) = 'WS_DUAL INK (Y/N)'
LEFT JOIN a_wiplotdetailsdata ie ON wld.wiplotdetailsid = ie.wiplotdetailsid AND ie.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ie.wipdatanamename)) = 'WS_INKED EDGES (Y/N)'
LEFT JOIN a_wiplotdetailsdata vq ON wld.wiplotdetailsid = vq.wiplotdetailsid AND vq.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(vq.wipdatanamename)) LIKE 'WS_100%VISUAL%QTY'
LEFT JOIN a_wiplotdetailsdata ntg ON wld.wiplotdetailsid = ntg.wiplotdetailsid AND ntg.waferscribenumber = wldd.waferscribenumber AND TRIM(UPPER(ntg.wipdatanamename)) = 'WS_NEW TOTAL GDPW'
WHERE c.containername =:lotID AND (TRIM(UPPER(wldd.wipdatanamename)) = 'WS_ACCEPT BIN1' OR ( (TRIM(UPPER(wldd.wipdatanamename)) LIKE 'WS_LASER TRIM ENERGY%' AND wl.specname LIKE '5207_%' )
OR (TRIM(UPPER(wldd.wipdatanamename)) LIKE 'WS_100%VISUAL%QTY' AND SUBSTR(wl.specname,0,4) = '5267' ) ) )
) wipdata
WHERE wipdata."Total Good DPW" <> 0 AND wipdata."Total Rejects" <> 0
ORDER BY wipdata.wafersequence;
我知道你们会帮忙的,非常感谢:)