我需要按“WO#”返回一行(VIEW_SPS_WO_OPERATION.SI_NUMBER为“WO#”)
返回的字段在多行中显示相同的值,因此我的连接可能不正确 除以下内容外:一个单独的“WO#”可以有多个NEXT_DELIVERY_DATE “VIEW_WOBOM.NEXT_DELIVERY_DATE”,我只需要带有最新日期的条目(最大?)。
我希望我很清楚。 在此先感谢您的帮助。
SELECT
VIEW_SPS_WO_OPERATION.COMPANY_NAME as Customer,
VIEW_SPS_WO_OPERATION. SI_NUMBER as "WO #",
VIEW_SPS_WO_OPERATION. PN as "Part Number",
VIEW_SPS_WO_OPERATION. DEPT_NAME as "Department",
VIEW_SPS_WO_OPERATION. TOTAL_PARTS as "Extended Price",
VIEW_SPS_WO_OPERATION.DESCRIPTION as Description,
VIEW_WO_SUB.WORK_TYPE as "Work Req.",
VIEW_SPS_WO_OPERATION.STATUS_DESC as Task,
VIEW_SPS_WO_OPERATION.ENTRY_DATE as "Rec Date",
VIEW_SPS_WO_OPERATION.DUE_DATE as "Qtd Date",
VIEW_SPS_WO_OPERATION.EST_COMP_DATE as "App. Date",
VIEW_WO_TASK_STATISTICS.SKILLS_EST_HOURS as "Est. Labor Hrs.",
VIEW_WO_TASK_STATISTICS.LABOR_HOURS as "Act. Labor Hrs.",
VIEW_WOBOM.NEXT_DELIVERY_DATE
FROM
GATCRGQCTL.VIEW_SPS_WO_OPERATION VIEW_SPS_WO_OPERATION,
GATCRGQCTL.VIEW_WO_SUB VIEW_WO_SUB,
GATCRGQCTL.VIEW_WO_TASK_STATISTICS VIEW_WO_TASK_STATISTICS,
GATCRGQCTL.VIEW_WIP_VALUATION VIEW_WIP_VALUATION,
GATCRGQCTL.WO_BOM WO_BOM,
GATCRGQCTL.VIEW_WOBOM VIEW_WOBOM
WHERE
VIEW_SPS_WO_OPERATION.SI_NUMBER = VIEW_WO_SUB. SI_NUMBER
AND
VIEW_WIP_VALUATION.WOO_AUTO_KEY = WO_BOM. WOO_AUTO_KEY AND
VIEW_SPS_WO_OPERATION.WOO_AUTO_KEY = VIEW_WIP_VALUATION.WOO_AUTO_KEY AND
WO_BOM.WOT_AUTO_KEY = VIEW_WO_TASK_STATISTICS.WOT_AUTO_KEY
AND
WO_BOM.WOT_AUTO_KEY = VIEW_WOBOM.WOT_AUTO_KEY
答案 0 :(得分:1)
您需要MIN(VIEW_WOBOM.NEXT_DELIVERY_DATE)
,并且在WHERE子句中,您需要将结果限制为VIEW_WOBOM.NEXT_DELIVERY_DATE >= Now()
的结果。
你如何计算NOW将取决于你的RDBMS。