$wpdb->num_rows doesn’t work

A few things I would do/add/change:

Instead of using a query function directly I would use $wpdb->get_results

Second, $wpdb->num_rows will work now.

Third: setup_postdata() is what you need to actually make use of the query outside of a loop. This means get_post(get_the_ID()) doesn’t apply to anything as there is no existing $post-ID to reference.

I understand what you are trying to do but you will need several more lines of code to get it done correctly. It seems a somewhat advanced function for someone who isn’t ready to write it.

In other words – you need to make sure your objects, arrays, and variables are properly set before you can effectively make use of them within the wpdb and/or wordpress class functions.