0

我有以下查询:

SELECT min(salesorder.SOM_SalesOrderID) AS salesorder,
    Item.IMA_ItemID,
    Item.IMA_ItemName,
    Customer.CUS_CorpName,
    WK.WKO_WorkOrderID,
    min(WK.WKO_OrigRequiredDate),
    WK.WKO_WorkOrderTypeCode,
    min(WK.WKO_RequiredDate),
    max(WK.WKO_LastWorkDate),
    min(wk.WKO_RequiredQty),
    wk.WKO_MatlIssueDate,
    min(SalesOrderDelivery.SOD_RequiredQty),
    Item.IMA_ItemTypeCode,
    Item.IMA_OnHandQty,
    min(SalesOrderDelivery.SOD_PromiseDate),
    min(WO.woo_operationseqID) AS seqid
FROM SalesOrder
INNER JOIN SalesOrderLine ON SalesOrder.SOM_RecordID = SalesOrderLine.SOI_SOM_RecordID
INNER JOIN SalesOrderDelivery ON SalesOrderLine.SOI_RecordID = SalesOrderDelivery.SOD_SOI_RecordID,
    WO.
INNER JOIN Item ON SalesOrderLine.SOI_IMA_RecordID = Item.IMA_RecordID
INNER JOIN WKO wk ON Item.IMA_ItemID = WK.WKO_ItemID
INNER JOIN Customer ON SalesOrder.SOM_CUS_RecordID = Customer.CUS_RecordID
INNER JOIN woo WO ON WO.WOO_WorkOrderID = WK.WKO_WorkOrderID
WHERE wk.WKO_StatusCode = 'Released'
    AND WO.WOO_StatusCode IS NULL
    AND SalesOrderDelivery.SOD_ShipComplete = 'false'
GROUP BY WK.WKO_WorkOrderID,
    Item.IMA_ItemID,
    Item.IMA_ItemName,
    Customer.CUS_CorpName,
    WK.WKO_WorkOrderTypeCode,
    wk.WKO_MatlIssueDate,
    Item.IMA_ItemTypeCode,
    Item.IMA_OnHandQty

我需要为每个 wk.wko_workorderid 返回 1 条记录。有一个字段不包括在内,我不知道如何获得。我需要检索与 min(WO.woo_operationseqID) 对应的 woo.woo_workcenterid 作为 seqid。我不能将它包含在一般查询中,因为表中有多个 workcenterid,我只想要作为最小操作序列记录一部分的特定一个。任何帮助,将不胜感激。

4

0 回答 0