一条sql语句
表ano111 112113表bnoyear count detail111 2009 1 hello111 2010 3 nice113 2010 2从a,b取数据,b取最大年份数据,生成结果如下,:表Cno countdetail1113 nice11201132select a.no,c.year,c.cnt,c.detailfrom a,(select * from b bbwhere not exists(select 1 fromb tb where bb.no=tb.no and bb.year<tb.year)) cwhere a.no=c.no(+) NO YEAR CNT DETAIL-------- ---------- ---------- ---------- 111 2010 3 nice 113 2010 2 112
页:
[1]