code: def to_outer_join_sql(self, orig_where = []):
      
      if not self.group:
        return str(self)
  
      select = str(self.select)
      fr = ','.join(self.fr)
      filter_q = "SELECT * FROM %s" % fr
      if self.where:
        filter_q += " WHERE %s" % self.wherestr
  
      select_clause = self.select.coalesced_str()
      groupby = ','.join(list(self.group))
      if self.order:
        orderby = ','.join(list(self.order))
      else:
        orderby = groupby
  
      if orig_where:
        orig_where = self.__wherestr__(orig_where)
        orig_where = ' WHERE %s' % orig_where
      else:
        orig_where = ''
  
      sql = """with bar as (%s)
      select %s
      from 
        ((select distinct %s from %s %s) as foo
          left outer join  
        bar using (%s)) 
      GROUP BY %s
      ORDER BY %s;""" % (filter_q, select_clause, groupby, fr, orig_where, groupby, groupby, orderby)
      print sql
      return sql
  
      """
      with right as (select * from lqm where WHERECLAUSE)
      select coalesce(sum(total_cost), 0), ccm_payor 
      from 
        ((select distinct ccm_payor from lqm) as payors 
          left outer join  
        right using (ccm_payor)) 
      GROUP BY ccm_payor;
      """
docs: Construct a SQL query that includes all groups that would have
      existed (exists in the orig_where clause) if the WHERE clause were not present