I have the following SQL table where I need to select one top exchange for each currency
Currency Exchange Date
USD NewYork 01/12/20
USD NewYork 01/11/20
USD NewYork 01/10/20
USD Montreal 01/10/20
CAD Montreal 01/07/20
CAD Montreal 01/06/20
CAD Beijing 01/06/20
I am using this query that uses partition
select distinct currency,
first_value(exchange) over (partition by currency order by count(*) desc) exchange,
max(count(*)) over (partition by currency) frequency
from tablename
group by currency, exchange
Result
Currency Exchange Frequency
USD NewYork 3
CAD Montreal 2
I need to to implement this in Linq