你能帮我在 linq 中生成这个 sql 查询吗?
SELECT DATA_MAX_qh.DATA_MAX,DATA_MAX_qh.[QUOT_CODE],[QUOT_VALUE],q.QUOT_DESCR,q.QUOT_DESCR_ALIAS
FROM [dbo].[QUOTATION_HISTORY] qh INNER JOIN
(SELECT MAX(QUOT_DATA) DATA_MAX, QUOT_CODE
FROM [dbo].[QUOTATION_HISTORY]
GROUP BY [QUOT_CODE]) DATA_MAX_qh on
DATA_MAX_qh.DATA_MAX = qh.QUOT_DATA and DATA_MAX_qh.QUOT_CODE = qh.QUOT_CODE
inner join [dbo].[AN_QUOTAZIONE] q on q.QUOT_CODE = qh.QUOT_CODE
我需要的第一件事是对表进行分组以获取最大日期及其匹配值,然后使用此过滤表进行更完整的选择
我从这个开始
var qhmaxdatevalue = from qh in context.QUOTATION_HISTORY
where qh.QUOT_DATA < System.DateTime.Now
group qh by qh.QUOT_CODE into qhgroupedbycode
select new { Quot_Code = qhgroupedbycode.Key, Data_Max = qhgroupedbycode.Max(x => x.QUOT_DATA) };
但现在我该如何继续?使用嵌套查询?
你能帮助我吗?