If I have understood you correctly,
- you have a custom post type Buildings which is parent to another post type Houses
- houses have a status custom field which can be 'sold' or 'for sale'
- you have a View to display buildings which should only include buildings that have child houses for sale
You are effectively reproducing the option from taxonomies to not display a taxonomy term if there are no posts attached, but using custom post types.
If you are comfortable creating custom code, such as writing a custom shortcode, then I would suggest that the optimal solution is to create the View which shows all buildings, write a custom shortcode that returns the number of child house posts with status of for sale, and use that to conditionally display the required content for your building. (For more on the views conditional shortcode see: https://toolset.com/documentation/views-shortcodes/#wpv-conditional)
But from your question I'm guessing you are looking for a solution which doesn't require custom coding. It's less intuitive, but here's how it works:
- Make a View for buildings that you will add to the page where you want it displayed. The View will display all buildings, not restricted by any filters. Include your ordering preferences.
- We are going to nest a View of Houses in the Loop output, but we need to create it first.
- Create the View that will show Houses for sale. We need to add 2 query filters so that we only return houses for the current Building (from our outer View) and which are for sale. See the attached screenshot.
- So, add a post relationship filter to select posts which are children of the current post in the loop, and
- Add a custom field filter to select posts where the status field is set to for-sale (your naming conventions may differ)
Now for what is output. Although we want to output buildings, our buildings view won't directly output anything. In the Loop output for the buildings View, just add a shortcode for the houses-for-sale view.
Now, in the Loop output for houses-for-sale we can add id="$building" to our shortcodes to say that we don't want to output content from the current post, which in our nested loop is a house, but rather from the parent building post. Here, in my houses for sale view output I am just displaying the building title, but you can design your output as you please:
<!-- wpv-loop-start -->
<wpv-loop>
<p>[wpv-post-title id="$building"]</p>
</wpv-loop>
<!-- wpv-loop-end -->
So, we loop through the buildings, and for each one we loop through its child houses that are marked for sale and for those print, not their own content, but the content of their parent building.
Now, if you haven't picked up on the likely problem already you will in testing. If a building has multiple child houses that are for sale then the building title we be printed for each of them, i.e. will be repeated.
So the final part of the solution is that in the Limit and Offset section of our houses for sale view you specify that we only want to display 1 item, i.e. we are not interested if there are multiple houses for sale for that business, just whether there are 0 or 1+.