View gist:cc4e921184d53c62c1d9e2848157f7bd
-- Select query
SELECT pst.`post_id`, pst.`post_title`, pst.`post_slug`
FROM (
SELECT min(pst.`post_id`) AS `min_id`, dst.`post_title`, cnt.`phone`, loc.`address`, loc.`street`, loc.`city`, loc.`state`, loc.`zip`, loc.`country`, COUNT(*) AS `cnt`
FROM (SELECT DISTINCT `post_title`
FROM `tableprefix_sabai_content_post`
WHERE `post_entity_bundle_type` = 'directory_listing' AND
`post_slug` REGEXP '[[:digit:]]') dst JOIN `tableprefix_sabai_content_post` pst
ON dst.`post_title` = pst.`post_title`
JOIN `tableprefix_sabai_entity_field_directory_contact` cnt