mysql - how to include zeros in the count in only one single query -


i have 1 table count, not using join. possible?

select engagement_type name, count(engagement_type) y events group engagement_type order engagement_type

but result 1 row count per engagement_type. want show count of accounts without engagement_type. these:

enter image description here

will appreciate answers! thanks!

if there lookup-table, engagementtypes, possible values of engagement types stored, can query table full list of types , left join events table in order corresponding count:

select t1.engagement_type name, count(t2.engagement_type) y engagementtypes t1 left join events t2 on t1.engagement_type = t2.engagement_type group t1.engagement_type order t1.engagement_type  

Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -