0

I want to count the number of times a name is produced in a table. I then want to group the output so that it only shows the name once with the count in the next column. So far I have the below code but it keeps giving me an error:

Select Name, count(*) as NoOfTimes
from CustName
where count(*) >= 3
group by Name;
Vamsi Prabhala
  • 48,685
  • 4
  • 36
  • 58
R.Sloshy
  • 57
  • 8

1 Answers1

2

Count() is known as an aggregate function.

To perform operations on the results of aggregate functions, you have to use HAVING instead of WHERE, like this:

Select Name, count(*) as NoOfTimes
from CustName
group by Name
having count(*) >= 3;
SlimsGhost
  • 2,849
  • 1
  • 10
  • 16