Querying across relationships in a template
OK, here is one solution I've come up with, which seems to work and (I think) avoids 1+ queries:

{% set groups = craft.entries({
    section: 'alert',
    with: [
        'country',
    ]
}).orderBy('postDate desc').status('live').all() | group(alert =&gt; alert.country[0]) %}
&lt;ul&gt;
    {% for country, alerts in groups | slice(0, 5) %}
        &lt;li&gt;
            {{ country }} &lt;!-- Cannot use country Entry --&gt;
            &lt;ul&gt;
                {% for alert in alerts %}
                    &lt;li&gt;{{ alert.title }}&lt;/li&gt;
                {% endfor %}
            &lt;/ul&gt;
        &lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;


I would prefer being able to handle this entirely in queries though