_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › SQL豐蠍

Contents

1 IN_LINE VIEW
2 IN_LINE VIEW襯 1
3 IN_LINE VIEW襯 2
4 DECODE
5 朱覯 覿願鍵 螻
6 VIEW UNION 伎 貎朱Μ


覿 伎 SQL 螳 ′朱Μ 螳. 伎 譬 蟾 貎朱Μ覓語 燕企慨襦 蟆給. 豌 覿覿 讌 螻覦 螳讌蠍 貎朱Μ覓語 燕企慨螻 襷讌襷覿覿 覿 貎朱Μ 焔レ 蠍磯蓋 れ 危エ覲願給. 企 SELECT 蠍磯蓋 牛朱襦, 伎 覓語 願屋ルレ 蠍碁 手 螳. 覿 願崖 覓語襯 れる 願屋 る 覿 豐覲願 手 給.

1 IN_LINE VIEW #


瑚 DBMS蟆 SQL襦 覲願 覓伎語 蟲螻, DBMS 蟆 蟆郁骸襯 企 襦 れ. 朱 貎朱Μ覓語 企 襦 蟆 . 襷 覿 IN_LINE VIEW襯 朱 讌 螻覦 螳讌蟆 蟆.
  1. SQL> SELECT EMPNO, ENAME, DEPTNO
  2.   2  FROM (SELECT * 
  3.   3        FROM EMP
  4.   4        WHERE DEPTNO = 20) TABLE1;
  5.  
  6.      EMPNO ENAME          DEPTNO
  7. ---------- ---------- ----------
  8.       7369 SMITH              20
  9.       7566 JONES              20
  10.       7788 SCOTT              20
  11.       7876 ADAMS              20
  12.       7902 FORD               20
  13.  
  14. SQL> SELECT EMPNO, ENAME, DEPTNO
  15.   2  FROM EMP
  16.   3  WHERE DEPTNO = 20;
  17.  
  18.      EMPNO ENAME          DEPTNO
  19. ---------- ---------- ----------
  20.       7369 SMITH              20
  21.       7566 JONES              20
  22.       7788 SCOTT              20
  23.       7876 ADAMS              20
  24.       7902 FORD               20
  25.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

豌 覯讌 貎朱Μ覓瑚骸 覯讌 貎朱Μ覓語 焔リ骸 蟆郁骸螳 螳給. 蠏碁 FROM SELECT 覓語朱 讌襯 蟆郁骸 企襦 豬蠍 蟆. VIEW朱 蟆 螳 企襦 讌 蟆郁骸襯 企襦 豬蠍 蟆. VIEW CREATE VIEW 覓語朱 襷れ 朱, れ螻 螳 .

  1. SQL> CREATE VIEW V_EMP_DEPT20
  2.   2  AS
  3.   3  SELECT * FROM EMP
  4.   4  WHERE DEPTNO = 20;
  5.  
  6. 觀郁 焔給.
  7.  
  8. SQL> SELECT * FROM V_EMP_DEPT20;
  9.  
  10.      EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM     DEPTNO
  11. ---------- ---------- --------- ---------- -------- ---------- ---------- ----------
  12.       7369 SMITH      CLERK           7902 80/12/17        800                    20
  13.       7566 JONES      MANAGER         7839 81/04/02       2975                    20
  14.       7788 SCOTT      ANALYST         7566 87/04/19       3000                    20
  15.       7876 ADAMS      CLERK           7788 87/05/23       1100                    20
  16.       7902 FORD       ANALYST         7566 81/12/03       3000                    20  
  17.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

讀, VIEW 螳 覦朱慨 蟯朱 螳 給. 譬伎 蟲覃 企螻 豈 語覃伎 朱 蟲覃 覿覿 蠍 覦 覲伎伎 蟆. VIEW 螳 企蟆 覲企 朱朱 覓企. 企蟆 CREATE VIEW襯 覃 DBMS 一危 SELECT覓語朱 蠍一 蟆れ 蠍磯螻(ろ螻 ), 企襦 豬蠍 . 蠏碁 襷 螳 覦朱慨 蟯 覈 蟆 襷れ 企れ 殊 蟆. 蠏碁 蟆 IN_LINE VIEW . IN_LINE VIEW 讌襯 襷 FROM 企 蟆 螳讌 讌覓語 蟆郁骸襯 襷. 讀, 豌覯讌 讌覓語 2 ~ 4 殊瑚讌 SELECT * FROM EMP WHERE DEPTNO = 20 蟆郁骸螳 TABLE1企朱 覲豺 螳讌 企 蟆.
  2  FROM (SELECT * 
  3        FROM EMP
  4        WHERE DEPTNO = 20) TABLE1;

企 IN_LINE VIEW 蠏 螳 襷れ 給. 所襷 覲旧″伎碁 蠍磯蓋 SELECT 覓語朱襷 螳 覲願 覓伎語 企 蟆 襷れ 企旧給. 伎 IN_LINE VIEW るジ 螳讌 襯 讌覓語 燕 覲企襦 蟆給.

2 IN_LINE VIEW襯 1 #

れ 螳 一危覯伎るゼ 螻 豌朱 螳 企れ 貎朱Μ覓語. 朱朱讌螻襯 螻, るジ 貉殊 SELECT 覈伎朱 覦 GROUP BY 伎 . 企 讌螻 GROUP BY 蟯螻 企至 るジ 貉殊 豢ロ 殊 螳螳 覓語給. れ螻 螳 貎朱Μ 所 豢レ 給.

  1. SQL> --  螳螳 讌覓伎 螳 襷 蠍 豢
  2. SQL> SELECT JOB, MAX(SAL)
  3.   2  FROM EMP
  4.   3  GROUP BY JOB;
  5.  
  6. JOB         MAX(SAL)
  7. --------- ----------
  8. ANALYST         3000
  9. CLE%RK          1300
  10. CLERK           1300
  11. MANAGER         2975
  12. PRESIDENT       5000
  13. SALESMAN        1600
  14.  
  15. 6 螳  給.
  16.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

蠏碁 貎朱Μ 螳 襷 蠍 覦 覯瑚讌 豢レ る 麹 螳. 蠏碁 磯Μ る IN_LINE VIEW襯 襾碁Μ襯 譟郁襷 企る 所 覲企ゼ 豢ロ 給. 願 蟾一 覿 讌 螻覦 螳譟り 覲企 蟆. 蟆曙磯 IN_LINE VIEW襯 螻 讌 螻覦企 蟆 覓伎瑚襯 給. 覿 願 企慨蠍 覦 殊 朱 願屋 覯襴 れ 蟆. 覿 貎朱Μ覓語 燕 蟆 企蟆 豢レ 襦 る 蟆企手 螳覃 れ一 蟆. 貎朱Μ覓語 螳 覲願 覓伎語 DBMS蟆 れ朱 讀, DBMS 旧 蟆. 貎朱Μ覓語 燕る 蟆 企 蟆螻 企 ろ蟆暑襯 牛 覲企ゼ 螳語る朱 蟆蟾讌 企朱 螻 る 蟆 朱 譯殊蠍 覦.

  1. SQL> --  螳螳 讌覓伎 螳 襷 蠍 覦  EMPNO, JOB, SAL 豢
  2. SQL> SELECT T1.EMPNO, T2.JOB, T2.MAX_SAL
  3.   2  FROM EMP T1, 
  4.   3         (SELECT JOB, MAX(SAL) AS MAX_SAL 
  5.   4          FROM EMP 
  6.   5          GROUP BY JOB) T2 
  7.   6  WHERE T1.JOB = T2.JOB
  8.   7  AND   T1.SAL = T2.MAX_SAL;
  9.  
  10.      EMPNO JOB          MAX_SAL
  11. ---------- --------- ----------
  12.       7788 ANALYST         3000
  13.       7902 ANALYST         3000
  14.       1111 CLE%RK          1300
  15.       7934 CLERK           1300
  16.       7566 MANAGER         2975
  17.       7839 PRESIDENT       5000
  18.       7499 SALESMAN        1600
  19.  
  20. 7 螳  給.
  21.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

磯Μ SELECT 蠍磯蓋覿覿 企 襾殊 螳襯 危エ覲伎給. 螳 襾殊 蟆 FROM . 蠏碁る FROM 企 SELECT 覿 蟆讌.

3 IN_LINE VIEW襯 2 #

  1. SQL> SELECT * FROM EMP;
  2.  
  3.      EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM     DEPTNO
  4. ---------- ---------- --------- ---------- -------- ---------- ---------- ----------
  5.       7369 SMITH      CLERK           7902 80/12/17        800                    20
  6.       7499 ALLEN      SALESMAN        7698 81/02/20       1600        300         30
  7.       7521 WARD       SALESMAN        7698 81/02/22       1250        500         30
  8.       7566 JONES      MANAGER         7839 81/04/02       2975                    20
  9.       7654 MARTIN     SALESMAN        7698 81/09/28       1250       1400         30
  10.       7698 BLAKE      MANAGER         7839 81/05/01       2850                    30
  11.       7782 CLARK      MANAGER         7839 81/06/09       2450                    10
  12.       7788 SCOTT      ANALYST         7566 87/04/19       3000                    20
  13.       7839 KING       PRESIDENT            81/11/17       5000                    10
  14.       7844 TURNER     SALESMAN        7698 81/09/08       1500          0         30
  15.       7876 ADAMS      CLERK           7788 87/05/23       1100                    20
  16.       7900 JAMES      CLERK           7698 81/12/03        950                    30
  17.       7902 FORD       ANALYST         7566 81/12/03       3000                    20
  18.       7934 MILLER     CLERK           7782 82/01/23       1300                    10
  19.       1111 MILLER     CLE%RK          7782 82/01/23       1300                    10
  20.  
  21. SQL> SELECT JOB, COUNT(*)
  22.   2  FROM EMP
  23.   3  GROUP BY JOB;
  24.  
  25. JOB         COUNT(*)
  26. --------- ----------
  27. ANALYST            2
  28. CLE%RK             1
  29. CLERK              4   --> 谿剰  蟆
  30. MANAGER            3
  31. PRESIDENT          1
  32. SALESMAN           4   --> 谿剰  蟆
  33.  
  34. 6 螳  給.      
  35.  
  36. SQL>  SELECT TBL_2.JOB 
  37.   2   FROM (SELECT MAX(COUNT) AS MAX_COUNT 
  38.   3         FROM (SELECT JOB, COUNT(*) AS COUNT
  39.   4               FROM EMP
  40.   5               GROUP BY JOB) T) TBL_1, 
  41.   6        (SELECT JOB, COUNT(*) AS COUNT 
  42.   7         FROM EMP 
  43.   8         GROUP BY JOB) TBL_2 
  44.   9   WHERE TBL_1.MAX_COUNT = TBL_2.COUNT;
  45.  
  46. JOB
  47. ---------
  48. CLERK
  49. SALESMAN
  50.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

4 DECODE #


伎 蟲豌伎 る 讌 襦 蟆給. 蠏碁 DECODE 蠏 螳 襷れ磯る 蟆 . DECODE 襯 伎覃 朱 危襴貅伎 IF 豌襴襯 給. 蠏碁覩襦 る狩伎 螻牛 DECODE (覓朱 DECODE る狩伎 螻牛.)襯 伎覃, 危襴貅伎 覲旧″ 豌襴襯 讌 蟆. 覓朱 一危襯 一危 豌襴 麹 語伎 DBMS 豌襴讌 螻 危襴貅伎 豌襴る 蟆 豌願 覲願朱 覯朱ゼ 覯螻 蟆 蟆. 豈 SQL 豈 覩襦 DECODE 誤 る 牛襦 蟆給. 蟲豌伎 SQL るジ 企 豪語 覃伎殊 谿瑚蠍 覦. 蠍一 襯 牛伎 IF豌襴襯 蟆 覲伎襴襦 蟆給. 蠎 覿伎 蠍一 蟆朱 襷 .

  1. SQL> SELECT CEIL(ROWNUM/3), EMPNO FROM EMP;
  2.  
  3. CEIL(ROWNUM/3)      EMPNO
  4. -------------- ----------
  5.              1       7369
  6.              1       7499
  7.              1       7521
  8.              2       7566
  9.              2       7654
  10.              2       7698
  11.              3       7782
  12.              3       7788
  13.              3       7839
  14.              4       7844
  15.              4       7876
  16.              4       7900
  17.              5       7902
  18.              5       7934
  19.              5       1111
  20.  
  21. 15 螳  給.
  22.  
  23. SQL> SELECT CEIL(ROWNUM/3) ID,
  24.   2  DECODE(MOD(ROWNUM,3), 1, EMPNO, NULL) NO1,
  25.   3  DECODE(MOD(ROWNUM,3), 2, EMPNO, NULL) NO2,
  26.   4  DECODE(MOD(ROWNUM,3), 0, EMPNO, NULL) NO3
  27.   5  FROM EMP;
  28.  
  29.         ID        NO1        NO2        NO3
  30. ---------- ---------- ---------- ----------
  31.          1       7369
  32.          1                  7499
  33.          1                             7521
  34.          2       7566
  35.          2                  7654
  36.          2                             7698
  37.          3       7782
  38.          3                  7788
  39.          3                             7839
  40.          4       7844
  41.          4                  7876
  42.          4                             7900
  43.          5       7902
  44.          5                  7934
  45.          5                             1111
  46.  
  47. 15 螳  給.
  48.  
  49.  
  50. SQL> -- CEIL(ROWNUM/3)襦 蠏碁9讌伎 蠏 蠏碁9伎 襾語 1,2,0 螻壱 MAX襯 豬
  51. SQL> SELECT CEIL(ROWNUM/3) ID,
  52.   2  MAX(DECODE(MOD(ROWNUM, 3), 1, EMPNO, NULL)) EMPNO1,
  53.   3  MAX(DECODE(MOD(ROWNUM, 3), 2, EMPNO, NULL)) EMPNO2,
  54.   4  MAX(DECODE(MOD(ROWNUM, 3), 0, EMPNO, NULL)) EMPNO3
  55.   5  FROM EMP
  56.   6  GROUP BY CEIL(ROWNUM/3);
  57.  
  58.         ID     EMPNO1     EMPNO2     EMPNO3
  59. ---------- ---------- ---------- ----------
  60.          1       7369       7499       7521
  61.          2       7566       7654       7698
  62.          3       7782       7788       7839
  63.          4       7844       7876       7900
  64.          5       7902       7934       1111
  65.  
  66. SQL> 
  67.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

5 朱覯 覿願鍵 螻 #

  1. --朱覯 覿願鍵
  2. SQL> SELECT EMP_ID.ID, EMP.EMPNO, ENAME, JOB
  3.   2  FROM (SELECT E2.EMPNO,
  4.   3               (SELECT (COUNT(*)+1) FROM EMP E1 WHERE E1.EMPNO>E2.EMPNO) AS ID
  5.   4        FROM EMP E2
  6.   5        ORDER BY ID) EMP_ID, EMP
  7.   6  WHERE EMP_ID.EMPNO = EMP.EMPNO;
  8.  
  9.         ID      EMPNO ENAME      JOB
  10. ---------- ---------- ---------- ---------
  11.          1       7934 MILLER     CLERK
  12.          2       7902 FORD       ANALYST
  13.          3       7900 JAMES      CLERK
  14.          4       7876 ADAMS      CLERK
  15.          5       7844 TURNER     SALESMAN
  16.          6       7839 KING       PRESIDENT
  17.          7       7788 SCOTT      ANALYST
  18.          8       7782 CLARK      MANAGER
  19.          9       7698 BLAKE      MANAGER
  20.         10       7654 MARTIN     SALESMAN
  21.         11       7566 JONES      MANAGER
  22.         12       7521 WARD       SALESMAN
  23.         13       7499 ALLEN      SALESMAN
  24.         14       7369 SMITH      CLERK
  25.         15       1111 MILLER     CLE%RK
  26.  
  27. 15 螳  給.
  28.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

れ螻 螳 ろ語 企 燕.

  1. SQL> CREATE TABLE AA (
  2.   2       COL1 VARCHAR(1),
  3.   3       COL2 NUMBER);
  4.  
  5. 企 焔給.
  6.  
  7. SQL> INSERT INTO AA VALUES ('A', 10);    
  8.  
  9. 1 螳  襷れ伎給.
  10.  
  11. SQL> INSERT INTO AA VALUES ('B', 20);
  12.  
  13. 1 螳  襷れ伎給.
  14.  
  15. SQL> INSERT INTO AA VALUES ('C', 10);
  16.  
  17. 1 螳  襷れ伎給.
  18.  
  19. SQL> INSERT INTO AA VALUES ('D', 30);
  20.  
  21. 1 螳  襷れ伎給.
  22.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

ろ襴渚碁 襷れ伎 企 れ螻 螳給.
C       COL2
- ----------
A         10
B         20
C         10
D         30
企 る螻 螳 襦 企り覃伎 蟆郁骸襯 企蟆 覓語.
C       COL2       COL3
- ---------- ----------
A         10         10
B         20         30
C         10         40
D         30         70

蠏碁 螻壱 覲願給.
  1. -- 螻壱蠍
  2. SQL> SELECT COL1, COL2
  3.   2  ,(SELECT SUM(T1.COL2) FROM AA T1 WHERE ASCII(T1.COL1) <= ASCII(T2.COL1)) AS COL3
  4.   3  FROM AA T2
  5.   4  ORDER BY COL1;
  6.  
  7. C       COL2       COL3
  8. - ---------- ----------
  9. A         10         10
  10. B         20         30
  11. C         10         40
  12. D         30         70
  13.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

覿 讌覓語 伎伎 一 蟲蠍磯煙 讌覓語 燕 蟆. 豌朱 企 覓語襯 螻 SELECT SELECT 蟆 給. 蟆 覓企 螳 讌覓語伎給.

6 VIEW UNION 伎 貎朱Μ #

朱 れ旧 企 燕. 願 VIEW UNION 覯 蠍一 れ . 螳 企 覿 讌覓誤 蟆 給 蟆碁, 朱 焔レ 螻るゼ 讌 螻 VIEW UNION 牛る 蟆 襦 れ牛蠍 覦.

  1. --れ旧  企 
  2. SQL> DROP TABLE TEST;
  3.  
  4. 企 給.
  5.  
  6. SQL> CREATE TABLE TEST( 
  7.   2  DATE_YYYY_MM CHAR(6), 
  8.   3  NAME CHAR(10), 
  9.   4  CODE CHAR(1), 
  10.   5  MONEY INT); 
  11.  
  12. 企 焔給.
  13.  
  14. SQL> INSERT INTO TEST VALUES ('200101', '蠍碁', '1', 100); 
  15.  
  16. 1 螳  襷れ伎給.
  17.  
  18. SQL> INSERT INTO TEST VALUES ('200101', '蠍碁', '2', 50); 
  19.  
  20. 1 螳  襷れ伎給.
  21.  
  22. SQL> INSERT INTO TEST VALUES ('200102', '蠍碁', '1', 100); 
  23.  
  24. 1 螳  襷れ伎給.
  25.  
  26. SQL> INSERT INTO TEST VALUES ('200102', '蠍碁', 'P', 110); 
  27.  
  28. 1 螳  襷れ伎給.
  29.  
  30. SQL> INSERT INTO TEST VALUES ('200103', '蠍碁', '1', 100); 
  31.  
  32. 1 螳  襷れ伎給.
  33.  
  34. SQL> INSERT INTO TEST VALUES ('200103', '蠍碁', '2', 50); 
  35.  
  36. 1 螳  襷れ伎給.
  37.  
  38. SQL> INSERT INTO TEST VALUES ('200103', '蠍碁', 'P', 110); 
  39.  
  40. 1 螳  襷れ伎給.
  41.  
  42. SQL> INSERT INTO TEST VALUES ('200103', '蠍碁', 'Q', 60); 
  43.  
  44. 1 螳  襷れ伎給.
  45.  
  46. SQL> SELECT * FROM TEST; 
  47.  
  48. DATE_Y NAME       C      MONEY
  49. ------ ---------- - ----------
  50. 200101 蠍碁     1        100
  51. 200101 蠍碁     2         50
  52. 200102 蠍碁     1        100
  53. 200102 蠍碁     P        110
  54. 200103 蠍碁     1        100
  55. 200103 蠍碁     2         50
  56. 200103 蠍碁     P        110
  57. 200103 蠍碁     Q         60
  58.  
  59. 8 螳  給.
  60.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

貎朱Μ CODE 螳 1, 2, P, Q 企蟆 4螳 螳 螳讌螻 企 螳 貊螳 1螻 P螳 螳 朱 P 蠍′, 2 Q螳 螳 朱 Q 蠍′ 豢る願 貎朱Μ. P, Q 螳 1, 2 貊 蠍′ 螳 る 蟆. P, Q 貊螳 1,2 貊螳 給. 1, 2 貊螳 ろ伎 P, Q貊螳 蟇 .

  1. SQL> --譴螳讌  觀  : SELECT 覓語 襯  觀一
  2. SQL> CREATE VIEW V_T1
  3.   2  AS
  4.   3  SELECT DATE_YYYY_MM, CODE, NAME, MONEY
  5.   4  FROM TEST
  6.   5  WHERE CODE = '1' OR CODE = '2';
  7.  
  8. 觀郁 焔給.
  9.  
  10. SQL> CREATE VIEW V_T2
  11.   2  AS
  12.   3  SELECT DATE_YYYY_MM, CODE, NAME, MONEY
  13.   4  FROM TEST
  14.   5  WHERE CODE = 'P' OR CODE = 'Q';
  15.  
  16. 觀郁 焔給.
  17.  
  18. SQL> SELECT * FROM V_T1;
  19.  
  20. DATE_Y C NAME            MONEY
  21. ------ - ---------- ----------
  22. 200101 1 蠍碁            100
  23. 200101 2 蠍碁             50
  24. 200102 1 蠍碁            100
  25. 200103 1 蠍碁            100
  26. 200103 2 蠍碁             50
  27.  
  28. SQL> SELECT * FROM V_T2;
  29.  
  30. DATE_Y C NAME            MONEY
  31. ------ - ---------- ----------
  32. 200102 P 蠍碁            110
  33. 200103 P 蠍碁            110
  34. 200103 Q 蠍碁             60
  35.  
  36. SQL> --  觀磯 讌螻螳 企 GROUP BY襯   る 蟆 覲伎譯朱 ...
  37. SQL> -- 豈 覲企 覈 GROUP BY, HAVING 覓語 讌螻 螳  蟆 覦 伎 
  38. SQL> -- GROUP BY 螳 蠎 讌螻 伎 る ろ企ゼ 讌 蠍磯ゼ... 
  39. SQL> CREATE VIEW V_T3 
  40.   2  AS 
  41.   3  SELECT DATE_YYYY_MM, CODE, NAME, MONEY 
  42.   4  FROM TEST 
  43.   5  GROUP BY DATE_YYYY_MM, CODE, NAME, MONEY 
  44.   6  HAVING CODE = 'P' OR CODE= 'Q'; 
  45.  
  46. 觀郁 焔給.
  47.  
  48. SQL> SELECT * FROM V_T3;
  49.  
  50. DATE_Y C NAME            MONEY
  51. ------ - ---------- ----------
  52. 200102 P 蠍碁            110
  53. 200103 P 蠍碁            110
  54. 200103 Q 蠍碁             60
  55.  
  56. SQL> --UNION ALL 伎 蟆郁骸讌 
  57. SQL> SELECT DATE_YYYY_MM, CODE, NAME, MONEY
  58.   2  FROM V_T1
  59.   3  WHERE NOT EXISTS (SELECT DATE_YYYY_MM 
  60.   4                    FROM V_T2
  61.   5                    WHERE V_T1.DATE_YYYY_MM = V_T2.DATE_YYYY_MM)
  62.   6  UNION ALL
  63.   7  SELECT DATE_YYYY_MM, CODE, NAME, MONEY 
  64.   8  FROM V_T2; 
  65.  
  66. DATE_Y C NAME            MONEY
  67. ------ - ---------- ----------
  68. 200101 1 蠍碁            100
  69. 200101 2 蠍碁             50
  70. 200102 P 蠍碁            110
  71. 200103 P 蠍碁            110
  72. 200103 Q 蠍碁             60
  73.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari

伎 貎朱Μ覓語 覈 危危螻 る る 貎朱Μ覓語 伎 蠍一 蟆.
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

覈 蠍郁 襷 譬磯. 蠏碁覩襦 語 螳 螳 襷 れるΥ 企. (覓企)