var _setList = (from f in _postgreDbContext.settlements
group f by ( new { f.settlement_code })into g
select new
{
deal_time = g.Max(m => m.deal_time),
g.Key.settlement_code
}).AsNoTracking().ToList();
create table cangku ( F_RQ datetime, F_BH VARCHAR(20), F_SL FLOAT )
INSERT INTO cangku VALUES('2012-05-31','C001',343) INSERT INTO cangku VALUES('2012-05-30','C001',34) INSERT INTO cangku VALUES('2012-05-30','C002',33) INSERT INTO cangku VALUES('2012-05-26','C002',23)
SELECT * FROM cangku T,(SELECT F_BH,MAX(F_RQ) rq FROM cangku GROUP BY F_BH) t2 where t.F_BH=t2.F_BH and t.F_RQ>=t2.rq