多个SUbqueries加入

时间:2016-06-06 13:40:10

标签: sql oracle join subquery

public class Foo{

   private int number;
   public Foo(){
      setup();
      doSthing();
   }

   private void doSthing(){
      number=10;
   }

   public void setup(){
   }

   protected int getNumber(){
      return number;
   }

   public void run(){
      getNumber();
      //Do blah blah...
    }    
}

我想用连接替换子查询;我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

SELECt rb.resource_id, MAX(re.code),MAX(rb.TYPE),
  MAX(CASE WHEN irb.language_id=1 THEN irb.NAME END) as nl_name, 
  MAX(CASE WHEN irb.language_id=21 THEN irb.NAME END) as de_name, 
  MAX(CASE WHEN irb.language_id=22 THEN irb.NAME END) as en_name
FROM resourcebase rb 
JOIN resort re ON (rb.resort_id=re.resort_id) 
LEFT JOIN i18n_resourcebase irb on (irb.resource_id = rb.resource_id)
AND re.code='RVRP' 
AND rb.TYPE='accommodationtype' 
AND rb.archived_from IS NULL 
AND re.archived_from IS NULL

GROUP BY rb.resource_id;