How do I get all categories with at least one entry I want all categories that have at least one entry that uses it.
You could do it like this:

{% set categories = craft.categories.relatedTo({
    sourceElement: craft.entries.limit(null)
}) %}


reference: https://craftcms.slack.com/archives/help/p1429030702000608