creo que ya lo tengo
Código SQL:
Ver originalSELECT
A1.PO_No,A7.Name,A1.Supplier_No,A5.Supplier_Code,A2.Line_Item_No,
A3.Item_No,A3.Description,A2.Unit_Price,A2.Unit,A1.Currency_Code,
A4.Supplier_No,A6.Supplier_Code,
A4.Unit_Price,A4.Lead_Time,
CASE
WHEN A2.Unit_Price > (SELECT MIN( Unit_Price) FROM Purchasing_v_Item_Supplier_Price_e
WHERE Item_Key = A2.Item_Key) THEN 'EXISTE UN MEJOR PRECIO'
WHEN A2.Unit_Price <= (SELECT MIN( Unit_Price) FROM Purchasing_v_Item_Supplier_Price_e
WHERE Item_Key = A2.Item_Key) THEN 'NO'
END,
(SELECT MIN( Unit_Price) FROM Purchasing_v_Item_Supplier_Price_e
WHERE Item_Key = A2.Item_Key)
FROM Purchasing_v_PO_e A1
INNER JOIN Purchasing_v_Line_Item_e A2 ON A1.PO_Key = A2.PO_Key
INNER JOIN Purchasing_v_Item_e A3 ON A3.Item_Key = A2.Item_Key
INNER JOIN Purchasing_v_Item_Supplier_Price_e A4 ON A4.Item_Key = A2.Item_Key
LEFT JOIN Common_v_Supplier_e A5 ON A5.Supplier_No = A1.Supplier_No
LEFT JOIN Common_v_Supplier_e A6 ON A6.Supplier_No = A4.Supplier_No
LEFT JOIN Common_v_Department_e A7 ON A7.Department_No = A1.Department_No
WHERE A7.Name = 'Produccion'
lo pueden revisar y comentar