mysql - SQL: COUNT() grouped results -


this current query:

select locationname, eventid events group locationname order locationname asc 

as can see it's grouped locationname because there several rows same locationname.

in output need list of "distinct" (grouped) locations behind every location there should total amount of each location.

so if in "events" 4 locationsname "congress center nyc" output should "congress center nyc (4)".

is there way expand query count()?

thanks!

this straightforward aggregate query.

select locationname, count(*) number   events  group locationname  order locationname 

if want specific formatting, can using first line of query.

 select concat(locationname, ' (', count(*), ')') 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -