Finding mode in SQL Server I have the below query which returns me the mode which is the most repeated value in a data set
select top 1 TargetPriceRec as mode 
from PricingRecurring  
Group By TargetPriceRec order by Count(*) desc

I get the most repeated value from this but the issue is that if there is no repeated value I am still getting the highest value in the dataset. How can I get an empty value if there are no repeating values in the dataset and also if there are multiple repeating values I still get an empty value since there is no single mode.
Any help is much appreaciated.
Thanks
You want to use the HAVING keyword
SELECT TOP 1 TargetPriceRec as mode 
FROM PricingRecurring   
GROUP BY TargetPriceRec  
HAVING COUNT(*) &gt; 1 
ORDER BY COUNT(*) DESC