I have table called info, and its data something like this:
FKUserID | CompletedTime | Type |
---|---|---|
1 | 2021-03-10 12:56:00.423 | 5 |
245 | 2021-03-10 12:46:46.977 | 5 |
1 | 2021-03-10 12:44:53.683 | 5 |
1 | 2021-03-10 12:40:54.733 | 5 |
1 | 2021-03-10 12:35:26.307 | 5 |
245 | 2021-03-10 11:11:33.887 | 5 |
245 | 2021-03-10 10:18:11.403 | 5 |
I need to get distinct userID data, and also with the maximum completed time of theirs CompletedTime
column
expected output is:
FKUserID | CompletedTime | Type |
---|---|---|
1 | 2021-03-10 12:56:00.423 | 5 |
245 | 2021-03-10 12:46:46.977 | 5 |
I need to do this using Linq
query
How can I do this, I did it using SQl, need it using Linq
SELECT FKUserID , MAX(CompletedTime)
from Info
where cast(CompletedTime as date) = '2021-03-10'
and Status = 5
GROUP BY FKUserID;