A lo que veo puedes hacer lo sig:
Código SQL:
Ver originalSELECT
T0.DocNum AS Oferta,
T1.SlpName AS Comercial,
T2.Zipcode AS CP,
T2.City AS Poblacion
INTO #temp
FROM
OQUT T0 LEFT JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
LEFT JOIN CRD1 T2 ON T0.CardCode = T2.CardCode
WHERE
T0.Series = '613' AND T2.Address LIKE 'FACTUR%'
SELECT
STR (Cuentas1.Neto/Cuentas1.Coste,10,3) AS FMT,
STR (Cuentas2.Neto/Cuentas2.Coste,10,3) AS FMO
FROM (
SELECT
SUM(T1.LineTotal) AS Neto,
SUM(T1.GrossBuyPr*T1.Quantity) AS Coste
FROM
OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry
WHERE
T0.DocNum EXISTS (SELECT * FROM #temp) AND T1.Itemcode NOT IN ('10000025','99999999')
) AS Cuentas1,
(
SELECT
SUM(T1.LineTotal) AS Neto,
SUM(T1.GrossBuyPr*T1.Quantity) AS Coste
FROM
OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry
WHERE
T0.DocNum EXISTS (SELECT * FROM #temp) AND T1.Itemcode ='10000025'
) AS Cuentas2
Saludos!!