Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kmddevdani/70e0ffbf309e9135cb49f19e31c51825 to your computer and use it in GitHub Desktop.
Save kmddevdani/70e0ffbf309e9135cb49f19e31c51825 to your computer and use it in GitHub Desktop.
magento2 find customers with at least 3 addresses, at least one of which is without city
select
count(*) addresses,
ce.entity_id,
email
from customer_address_entity cae
join customer_entity ce ON cae.parent_id = ce.entity_id
where ce.is_active = 1
and cae.city = ''
group by ce.entity_id
having addresses > 2 -- delete this line, if you also want to show customers that have only one address
order by ce.entity_id asc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment