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 - How to display all orders for a single product showing the most recent first? Woocommerce -

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

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -