$wpdb is queried but results don’t show

Refer to the Codex page for setup_postdata():

Important: You must make use of the global $post variable to pass the post details into this function, otherwise functions like the_title() don’t work properly…

Also note that you can use WP_Query to do these queries, rather than writing raw SQL.