zoukankan      html  css  js  c++  java
  • 【sas sql proc】inner join or outer join

     1 proc sql;
     2     title 'table 1+11';
     3     select * from mysas.ifthen1,mysas.ifthen11;
     4 quit;
     5 
     6 proc sql;
     7     title 'table 1';
     8     select * from mysas.ifthen1;
     9     
    10     title 'table11';
    11     select * from mysas.ifthen11;
    12 quit;

    第一段显示的是两表联合的笛卡尔积结果。

    第二段仅是分别显示两表。

     1 proc sql;
     2     title 'table1 inner jion table11';
     3     select a.gtone as g from mysas.ifthen1 a,mysas.ifthen11 b
     4     where a.gtone=b.gtone;
     5 quit;
     6 proc sql;
     7     title 'table1 inner jion table11';
     8     select a.gtone  'g' from mysas.ifthen1 a,mysas.ifthen11 b
     9     where a.gtone=b.gtone;
    10 quit;

    行的别名,两种方式一种是标签,另一种是另起名。

     from where 和inner join +on的作用一致 inner join +on是为了和left/right join on 相统一。

    1 proc sql;
    2     title 'self join';
    3     select a.gtone,b.shen
    4     from mysas.ifthen1 a,mysas.ifthen1 b
    5     where a.date=b.date;
    6 quit;

    用别名可以实现自身与自身的查询。

  • 相关阅读:
    第三周学习进度
    四则运算之结对开发
    第二周学习进度
    单元测试
    构建之法阅读笔记03
    本周学习进度
    四则运算三
    构建之法阅读笔记02
    本周学习进度
    按照Right-BICEP要求设计的测试用例
  • 原文地址:https://www.cnblogs.com/colipso/p/2942290.html
Copyright © 2011-2022 走看看