none
Multiple nested selects in SQL - How to replicate in Linq RRS feed

  • Question

  • I have the following SQL query which I'm scratching my head on how to replicate in Linq.

    SELECT X.ITMGEDSC, (SUM(X.[ENDQTY_I]) - SUM(X.[ORDERLINES])) AS AVAIL
    FROM
    (SELECT T1.[MANUFACTUREORDER_I],T2.[ITMGEDSC],T1.[ENDQTY_I],
    	(SELECT (COUNT(VW.[MANUFACTUREORDER_I]) - 1) 
    	FROM [PLCD].dbo.[vw_WIP_Srl] VW
    	WHERE VW.[MANUFACTUREORDER_I] = T1.[MANUFACTUREORDER_I]
    	GROUP BY VW.[MANUFACTUREORDER_I]) AS ORDERLINES
    FROM [PLCD].dbo.[vw_WIP_Srl] T1 
    INNER JOIN [PLCD].dbo.IV00101 T2 ON T2.ITEMNMBR = T1.ITEMNMBR
    GROUP BY T1.[MANUFACTUREORDER_I],T2.[ITMGEDSC],T1.[ENDQTY_I]) AS X
    GROUP BY X.ITMGEDSC
    

    Sample output for this would be;

    A10099      5.00000
    A10098      25.00000
    A10034      6.00000
    A10065      10.00000

    Friday, October 8, 2010 8:16 PM

Answers

All replies