数据:
列1  列2  列3  列4
a    b    c    d结果:
a-b-c-d求sql语句实现

解决方案 »

  1.   

    select 列1||'-'||列2||'-'||列3||'-'||列4 from table  oracle数据库
      

  2.   

    --wm_concat()函数用法
    with tb as (
    select '王' name,'数学' course,  11  type,  '2011-11-30 18:11:00'   time from dual union all
    select '王' , '数学', 11, '2011-11-30 18:11:00' from dual union all
    select '王' , '语文', 12, '2011-10-30 18:11:00' from dual union all
    select '张' , '数学', 11, '2011-11-30 18:11:00' from  dual 
    ) select tt.name, wm_concat(tt.km), wm_concat(tt.sj)
      from (
      select name,
             to_char(course),
             to_char(t.a) as km,
             to_char(type) || '/' || to_char(to_date(time,'yyyy-mm-dd hh24:mi:ss'), 'mm.dd') as sj
        from (select name, course, count(1) a, time, type
                from tb
               group by name,course,time,type) t
    ) tt
     group by tt.name这种问题太多了,WM_CONCAT函数用法,网上一查一大把。
      

  3.   


    with t as(
    select 'a' zd1,'b' zd2,'c' zd3,'d' zd4 from dual
    )select zd1||'-'||zd2||'-'||zd3||'-'||zd4 from t
      

  4.   

    ZD1||'-'||ZD2||'-'||ZD3||'-'||
    ------------------------------
    a-b-c-d
      

  5.   

    SELECT 'a' ||'-'|| 'b'||'-'||'c'||'-'||'d' col  from dual
      

  6.   

    跟你说的wm_concat没什么关系吧,同一列才用这个函数。不同的列直接用||字符连接就ok了额。