How to Count More Than One Row

I am going to share how to count more than one row in SQL. Suppose You have list of user details and you want count more then one row. In bellow example you can use sql query to get data.

Example

id name Date
1 umesh 2016-11-01
2 dinesh 2016-11-01
3 umesh 2016-11-01
4 rajesh 2016-11-01
5 rajesh 2016-11-01
What I want:
name Date count_name
rajesh 2016-11-01 2
umesh 2016-11-01 2

SELECT `name`,`date`, COUNT(`name`) AS `count_name` FROM test1 GROUP BY `name` 
HAVING ( COUNT(`name`) > 1 )

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments