Greetings.
I think i might be getting too adventurous.
can anyone see an issue with the following. The other select works on its own and the inner select works. there are matching values of the OPBEL field but i get this error message.
Incorrect syntax near the keyword 'EXISTS'.
DECLARE @START DATETIME
DECLARE @END DATETIME
SET @START = '20100101'
SET @END = '20100131'
DECLARE @GROSSINVOICED REAL
DECLARE @REVERSED REAL
DECLARE @INVOICED REAL
-------------------------------------------------------------
-- Determine GROSS INVOICED $
SELECT D.* FROM [SAP_Reporting].[dbo].[DFKKOP] as D
WHERE D.[BUDAT] BETWEEN @START AND @END
AND D.[HVORG] IN ('0008','0009')
WHERE D.[OPBEL] EXISTS
(SELECT F.*
FROM [SAP_Reporting].[dbo].[FKKMAZE] AS F
WHERE EXISTS
(SELECT F1.[OPBEL],MAX(F1.[AUSDT])
FROM [SAP_Reporting].[dbo].[FKKMAZE] AS F1
GROUP BY F1.[OPBEL])
AND F.[MAHNS] = '1');
many thanks