我自己写出来了,不知效率如何
select DBMS_RANDOM.RANDOM,c.id ,wmsys.wm_concat(c.name) end from 
(
select rownum as id, a.name from tab_a a where rownum<5
union all
select rownum as id,b.name from tab_b b where rownum<5
) c
group by c.id

解决方案 »

  1.   

    为什么不直接合并?
    select a.id,a.name||b.name from tab_a a,tab_b b where a.id=b.id order by 1
      

  2.   

    我没表达明白,关键是两个表没有任何关联,要做到的就是两个表各取十条数据把两个name值拼接成一句话显示
      

  3.   

    为什么要用GROUP BY,直接连接啊。
    select t1.rn, t1.name || t2.name
      from (select rownum rn, t1.name from t1 where rownum < 5) t1,
           (select rownum rn, t2.name from t2 where rownum < 5) t2
     where t1.rn = t2.rn
      

  4.   

    select a.name||b.name from a,b 即可
      

  5.   

    select a.id,a.name||b.name name from a,b where a.id=b.id,得附加匹配条件
      

  6.   

    为什么要用GROUP BY,直接连接啊。
    select t1.rn, t1.name || t2.name
      from (select rownum rn, t1.name from t1 where rownum < 5) t1,
           (select rownum rn, t2.name from t2 where rownum < 5) t2
     where t1.rn = t2.rn额 楼主说了 表没有关联的、
      

  7.   

    为什么要用GROUP BY,直接连接啊。
    select t1.rn, t1.name || t2.name
      from (select rownum rn, t1.name from t1 where rownum < 5) t1,
           (select rownum rn, t2.name from t2 where rownum < 5) t2
     where t1.rn = t2.rn额 楼主说了 表没有关联的、自己查个行号当关联,多套一层而已。
      

  8.   

    SELECT A.ID,A.NAME||B.NAME AS NAME FROM T_A A JOIN T_B B ON A.ID=B.ID
    两个表join下,合并字符串就好
      

  9.   

    为什么要用GROUP BY,直接连接啊。
    select t1.rn, t1.name || t2.name
      from (select rownum rn, t1.name from t1 where rownum < 5) t1,
           (select rownum rn, t2.name from t2 where rownum < 5) t2
     where t1.rn = t2.rn
    为什么要写的这么麻烦啊
    这样:
    select  t1.no, t1.name||t2.name from t1,t2 where t1.no=t2.no;不是很简单吗
      

  10.   


    SELECT A.ID,A.NAME||B.NAME AS NAME FROM T_A A JOIN T_B B ON A.ID=B.IDok