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
Post a Comment