I have two columns:
INDEX NAME
125 john
125 dave
125 dave
130 john
131 dave
I want to return only the name with the most number of occurrences. Then I want to put the string into a variable. What’s a query that I can use to achieve this?
This is with SQL Server 2008 and C#
Try this, it may give you what you are looking for.
This is similar to what you tried originally. Just move the count() to the order by, rather than the select list.