Click here to Skip to main content
15,501,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
select top 1 COUNT(Hatch) AS hatchs,Hatch
from TestDemo
where Deck='B'
group by Hatch
order by hatchs desc

What I have tried:

select top 1 COUNT(Hatch) AS hatchs,Hatch
from TestDemo
where Deck='B'
group by Hatch
order by hatchs desc
Posted
Updated 10-Jan-21 21:14pm
v2
Comments
Maciej Los 11-Jan-21 2:08am    
What have your tried till now?

1 solution

Try:
C#
var result = TestDemoContext
    .GroupBy(x=> x.Hatch)
    .Select(grp=> new {hatches = grp.Count, Hatch = grp.Key})
    .OrderByDescending(x=> x.hatches)
    .First();


Note: NOT tested!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900