Helo everybody.......hope someone can help me in this error...... Thanks.
When i connect this to my crystal report 11, the error shown:
Failed to retrive data from the database.
Details: 21000:[Microsoft][ODBC SQL Server Driver][SQL Server]Subquery returned more than one value. This is not permitted when the subquery follows =, !=, <, <=, >, >= or when subquery is used as an expression.
[Database vendor code:512]
This is the sql i do, i dono how to correct it.....Please advise...thanks
-------------------------------------------------------------------------------------------
SELECT TOP 100 PERCENT *,
(SELECT f.[Costing sum 1 (WCS16/KOCSU1)]
FROM (SELECT [Item number], [Costing Type], MAX(CostingDate) AS Maxcostingdate
FROM dbo.FT_KJCF_ProdCosting6
WHERE ([Item number] = T1.[Item Number]) AND (CostingDate <= T1.[Accounting Date]) AND Division = T1.[Division]
GROUP BY [Item number], [Costing type]
HAVING ([Costing type] = '3')) x INNER JOIN
dbo.FT_KJCF_ProdCosting6 f ON f.[Item number] = x.[Item number] AND f.CostingDate = x.Maxcostingdate AND
f.[Costing type] = x.[Costing Type]) AS Material_Cost,
(SELECT f.[Value component B01] + f.[Value component B02] + f.[Value component B03]
FROM (SELECT [Item number], [Costing Type], MAX(CostingDate) AS Maxcostingdate
FROM dbo.FT_KJCF_ProdCosting6
WHERE ([Item number] = T1.[Item Number]) AND (CostingDate <= T1.[Accounting Date]) AND Division = T1.[Division]
GROUP BY [Item number], [Costing type]
HAVING ([Costing type] = '3')) x INNER JOIN
dbo.FT_KJCF_ProdCosting6 f ON f.[Item number] = x.[Item number] AND f.CostingDate = x.Maxcostingdate AND
f.[Costing type] = x.[Costing Type]) AS Labor_Cost,
(SELECT f.[Value component B04] + f.[Value component B05] + f.[Value component B06] + f.[Value component B07] + f.[Value component B08] + f.[Value component B09]
+ f.[Value component B10] + f.[Value component B11] + f.[Value component B12]
FROM (SELECT [Item number], [Costing Type], MAX(CostingDate) AS Maxcostingdate
FROM dbo.FT_KJCF_ProdCosting6
WHERE ([Item number] = T1.[Item Number]) AND (CostingDate <= T1.[Accounting Date]) AND Division = T1.[Division]
GROUP BY [Item number], [Costing type]
HAVING ([Costing type] = '3')) x INNER JOIN
dbo.FT_KJCF_ProdCosting6 f ON f.[Item number] = x.[Item number] AND f.CostingDate = x.Maxcostingdate AND
f.[Costing type] = x.[Costing Type]) AS OverHead_Cost
FROM dbo.FT_KJCF_GP_Margin T1
ORDER BY Division, [Item number]
----------------------------------------------------------------------------------------