Add a JOIN with a subquery into a views query Here's my SQL, which I am trying to include in hook_views_query_alter() to modify the uc_catalog view (from Ubercart 3):

JOIN (
   SELECT uc_products.nid, MIN(uc_products.sell_price) AS min_price
   FROM uc_products
   JOIN node as n ON n.nid = uc_products.nid
   WHERE uc_products.nid IN
   (
     # in an ideal world, this is the WHERE statement from my views query
     SELECT ti.nid AS nid
     FROM taxonomy_index ti
     WHERE ti.tid = :db_condition_placeholder_1
     AND n.status = :db_condition_placeholder_2
     AND n.type IN :db_condition_placeholder_3
     GROUP BY uc_products.model
   )
 ) AS s2
 ON node.nid = s2.nid AND uc_products.sell_price = s2.min_price


I am confused as to how to make this work with the tools in views_plugin_query_default since this SQL has a subquery, etc. that is more complex than a simple JOIN statement.  I am having a hard time conceptualizing using add_relationship or add_table to make this work.  Is there something about $join building I don't understand.
After some work this problem was solved with the Views Field View module.