Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

LINQ query to get the top 1 from each group by first date

$
0
0

I have the SQL query .. How to do the same in linq

;WITH cte AS
(
SELECT [TYPE]
,[SEC_ID]
,[STDATE]
,[FILENM],
ROW_NUMBER() OVER (PARTITION BY [SEC_ID] ORDER BY [STDATE] asc) AS rn
FROM [CFileData]
)
SELECT *
FROM cte
WHERE rn = 1


Viewing all articles
Browse latest Browse all 1698

Trending Articles