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

php - Autoloader issue not returning Class -

python - Getting next two indexes regardless of current index -

ruby - Prevent Custom Validation Error on Association -