LINQ to SQL get grouped MIN with JOIN

Posted by Ira Rainey on Stack Overflow See other posts from Stack Overflow or by Ira Rainey
Published on 2010-04-19T17:19:28Z Indexed on 2010/04/19 17:23 UTC
Read the original article Hit count: 665

I'm having trouble with a LINQ to SQL query getting the min value using Visual Basic. Here's the SQL:

SELECT RC.AssetID, MIN(RC.RecCode) AS RecCode, JA.EngineerNote from JobAssetRecCode RC
JOIN JobAssets JA ON JA.AssetID = RC.AssetID AND JA.JobID = RC.JobID
WHERE RC.InspState = 2 AND RC.RecCode > 0
AND RC.JobID = @JobID
GROUP BY RC.AssetID, JA.EngineerNote;

I seem to be going around in circles here with grouping etc not managing to get it working. Any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about visual-basic