I want count the number of times a single data occured in a column, how can I achieve that using mysqli. For instance I want to know the number of times Victor appeared in the column of name.
Asked
Active
Viewed 40 times
-2
-
2Does this answer your question? [SQL Server query - Selecting COUNT(\*) with DISTINCT](https://stackoverflow.com/questions/1521605/sql-server-query-selecting-count-with-distinct) – Tigran Babajanyan Feb 26 '21 at 06:45
3 Answers
0
If you're using SQL server: SELECT name, count(1) from Tablename where name like 'Victor' group by name
This query will give you results like - eg Victor appeared 22 times: Victor 22
Is this what you're looking for? Please provide more information so its easier to assist.

Anu
- 306
- 2
- 11
0
Try window functions
SELECT ROW_NUMBER() OVER(PARTITION BY Name ORDER BY Name DESC)
AS Total, Name from table

Jatin Morar
- 164
- 1
- 7
0
this one will give you count of records with name='Victor'
select count(name) as cnt from t where name='Victor'
this one will give you all names with counts
select name, count(1) as cnt
from t
group by name
order by name

HainKurt
- 134
- 6