select a.t_name,a.t_date t_in,a.t_inorout t_out,b.t_date d_out,b.t_inorout t_come
from (select * from table_name where t_inorout='出门') a,
(select * from table2 where t_inorout='回来') b
where a.t_name=b.t_name 
其中t_name表示姓名,t_date表示日期,t_inorout表示出去或回来,table_name该表的表名。

解决方案 »

  1.   

    select a.姓名,a.日期,a.操作,b.日期,b.操作
    from yourtable a,yourtable b
    where a.姓名=b.姓名
      

  2.   

    select a.姓名,a.日期,a.操作,b.日期,b.操作
    from yourtable a,yourtable b
    where a.姓名=b.姓名
    and a.姓名='张三'
      

  3.   

    引用 回复人: baojianjun(包子)兄的方法:
    select a.t_name,a.t_date,a.t_inorout,b.t_date,b.t_inorout
    from table2 a,table2 b
    where a.t_name=b.t_name and a.t_inorout='出门' and b.t_inorout='回来'其中t_name表示姓名,t_date表示日期,t_inorout表示出去或回来,table_name该表的表
      

  4.   

    select * from (select  a.name||a.T_date||a.out_back||b.T_date||b.out_back  aaa,rank() over(partition by a.name order by a.name||a.T_date||a.out_back||b.T_date) rm from (select * from tab1 c order by c.name,c.out_back) a,(select * from tab1 d order by d.name,d.out_back) b where a.name=b.name and a.out_back<>b.out_back) where rm=1;
      

  5.   

    select 姓名,max(decode(操作,'出门',日期)),'出门',max(decode(操作,'回来',日期)),'回来' from tabname group by 姓名