最后一句是AND C.C_ID = 2

解决方案 »

  1.   

    SQL> select * from a1;BBB
    ----------
    101
    102
    103
    104
    105SQL> select * from a2;BBB        CCC
    ---------- --------------------
    101
    102
    105SQL> select * from a1,a2 where a1.bbb(+)=a2.bbb;BBB        BBB        CCC
    ---------- ---------- --------------------
    101        101
    102        102
    105        105SQL> select * from a1,a2 where a1.bbb=a2.bbb(+);BBB        BBB        CCC
    ---------- ---------- --------------------
    101        101
    102        102
    103
    104
    105        105SQL>
      

  2.   

    bzszp(SongZip):
    你好:你能用我提供的数据来测试一下吗,因为还有条件限制。我是这样写的
    SELECT A.A_ID1,A.A_ID2,A.A_NAME,B.B_NAME,C.C_NAME
    FROM A,B,C
    WHERE A.A_ID1 = B.A_ID1
        AND A.A_ID2 = B.A_ID2
        AND B.B_ID = 1
    A.A_ID1 = C.A_ID1
        AND A.A_ID2 = C.A_ID2
        AND C.B_ID = 2
      

  3.   

    对不起,不小心按了回复
    bzszp(SongZip):
    你好:你能用我提供的数据来测试一下吗,因为还有条件限制。我是这样写的
    SELECT A.A_ID1,A.A_ID2,A.A_NAME,B.B_NAME,C.C_NAME
    FROM A,B,C
    WHERE A.A_ID1 = B.A_ID1(+)
        AND A.A_ID2 = B.A_ID2(+)
        AND B.B_ID = 1
        AND A.A_ID1 = C.A_ID1(+)
        AND A.A_ID2 = C.A_ID2(+)
        AND C.C_ID = 2
      

  4.   

    我没有建立表的权限。因此没法测试,但是我觉得上面我写的语句虽然是正确的,但是得不到我要得结果的。
    以下面我用的实际sql来说明。
    select a.order_num in_num,
    '北京仓库' as whs_name,
    a.source,
    b.wm_date as in_date,
    a.mat_num,
    c.wm_date as out_date,
    d.order_num out_num,
    b.sap_mnt
    from T_ORDER a,T_EXEC_SUMMARY b,T_EXEC_SUMMARY c,T_REVERSE_RECORD d
    where a.biz_code = b.biz_code(+)
    and a.order_num = b.order_num(+)
    and a.order_pos = b.order_pos(+)
    and b.order_num = c.order_num(+)
    and b.order_pos = c.order_pos(+)
    and a.rev_num = d.rev_num(+)
    and a.biz_code = 'CI'
    and c.biz_code = 'CO'
    and b.rank_id = '5'
    and c.rank_id = '1'
    and d.biz_code = 'RE'
    其中表T_REVERSE_RECORD中没有数据。查询结果为空。
    但是只要我把and d.biz_code = 'RE'去掉,就能够查询出数据。
    请问如何解决这个问题
      

  5.   

    试试:select a.order_num in_num,
    '北京仓库' as whs_name,
    a.source,
    b.wm_date as in_date,
    a.mat_num,
    c.wm_date as out_date,
    d.order_num out_num,
    b.sap_mnt
    from T_ORDER a,T_EXEC_SUMMARY b,T_EXEC_SUMMARY c,(select * from T_REVERSE_RECORD where biz_code = 'RE') d
    where a.biz_code = b.biz_code(+)
    and a.order_num = b.order_num(+)
    and a.order_pos = b.order_pos(+)
    and b.order_num = c.order_num(+)
    and b.order_pos = c.order_pos(+)
    and a.rev_num = d.rev_num(+)
    and a.biz_code = 'CI'
    and c.biz_code = 'CO'
    and b.rank_id = '5'
    and c.rank_id = '1'
      

  6.   

    08:32:39 SQL> select * from a;    A_ID1     A_ID2 A_NAME
    --------- --------- ----------
            1         1 A_11
            2         1 A_21
            3         1 A_31实际:60
    08:33:28 SQL> select * from b;    A_ID1     A_ID2      B_ID B_NAME
    --------- --------- --------- ----------
            1         1         1 B_111
            1         1         2 B_112实际:50
    08:33:32 SQL> select * from c;    A_ID1     A_ID2      C_ID C_NAME
    --------- --------- --------- ----------
            2         1         1 C_211
            2         1         2 C_212实际:40
    08:33:36 SQL> select a.*,b.b_name,c.c_name from a,
    08:33:42   2  (select * from b where b_id=1) b,//如果要加条件加在此处
    08:33:42   3  (select * from c where c_id=2) c
    08:33:43   4  where a.a_id1=b.a_id1(+) and a.a_id2=b.a_id2(+)
    08:33:43   5  and a.a_id1=c.a_id1(+) and a.a_id2=b.a_id2(+);    A_ID1     A_ID2 A_NAME     B_NAME     C_NAME
    --------- --------- ---------- ---------- ----------
            1         1 A_11       B_111
            2         1 A_21                  C_212
            3         1 A_31实际:70
    08:33:43 SQL>