select no,money
from (select dscardno no,money from a
      union all
      select cardno no ,money from b) t
group by no

解决方案 »

  1.   

    select no,max(money)
    from (select dscardno no,money from a
          union all
          select cardno no ,money from b) t
    group by no
    不好意思
    漏了关键字了
      

  2.   

    update b set money=(select money from a where a.dscardno=b.cardno)
    where exists (select 1 from a where a.dscardno=b.cardno);update b set money=nvl((select money from a where a.dscardno=b.cardno),money);
      

  3.   

    udpate b set money=(select money from a where a.dscorno=b.codno) 
    where b.cardno in (select dscardno from a)
      

  4.   

    真的没有高手吗??
    这个应该很简单的把
    我会在MSSQL里用,但在oracle中就不能用了
      

  5.   

    上面几个人提供的SQL语句到底发生什么错误?能贴出来吗?
    也方便别人帮你分析,没有互动的话心有余而力不足啊~~说实话,简单的一个“不行”很让人心冷。
      

  6.   

    SQL> select * from a;DSCARDNO        MONEY
    ---------- ----------
    10001               5
    10003               6
    10004               3SQL> select * from b;CARDNO          MONEY
    ---------- ----------
    10001               1
    10002               1
    10003               1
    10004               1SQL> update b set money=(select money from a where a.dscardno=b.cardno)
      2  where exists (select 1 from a where a.dscardno=b.cardno);已更新3行。SQL> select * from b;CARDNO          MONEY
    ---------- ----------
    10001               5
    10002               1
    10003               6
    10004               3SQL> 用的zmgowin(hermit)的语句,请问哪里不行了?
      

  7.   

    呵呵,如果不想用snowy_howe(天下有雪) 兄的,用我这个试试,其实他那个应该不错的,我这个比较笨了点。
    update b set money=decode((select money from a where a.dscardno=b.cardno),null,money,(select money from a where a.dscardno=b.cardno))
      

  8.   

    为什么都说可以呢,我用的是oracle9i,sql tools工具
      

  9.   

    我是用oracle 客户端的sql*plus工具连接数据库的,不知道你说的SQL TOOLS工具又是什么呢?
    请多提供一些错误情况,大家帮你分析问题好吗?
    如果该TOOLS工具不提供错误信息,那么我建议你抛弃它,因为不够友好~~~
    如果提供错误信息,请原封不动的拷贝到CSDN上来,好吗?
      

  10.   

    update b set b.money=(select a.money from a where a.dscardno = b.dscardno)
    where exists (select 1 from a where a.dscardno = b.cardno);update b set b.money=(select a.money from a where a.dscardno = b.dscardno)
    where b.dscardno in (select a.dscardno from a);update b set b.money=nvl((select a.money from a where a.dscardno=b.cardno),money);