How to count entry by refrenceName? my sql query is
SELECT GROUP_CONCAT(refrenceName)
FROM attendance
where event='4'
GROUP BY refrenceName
HAVING ( COUNT(refrenceName) > 0 )
and showing result below
but how to count? I want Ashish(6), Babli(1)Rebecca(5) pls help me
SELECT concat(refrenceName,"(",count(refrenceName),")")
FROM attendance
where event='4'
GROUP BY refrenceName
HAVING ( COUNT(refrenceName) > 0 );
If you use GROUP_CONCAT for reference name, it will show result as reference name with comma separated values (like : Ashish,Ashish,Ashish,Ashish,Ashish,Ashish)
As per your expected output, you want to show only the name-not to be duplicated in the result, along with count.
So Hereby concatnating the referenceName with count(referenceName) as we have already groupped by the same column referenceName.