请教一个关于informix语句的问题
情况是这样的,有一个表有以下字段:zh,fse,rq
其中有很多记录zh字段是相同的,我只想取出其中rq最大的那条记录的fse,请教这个语句如何写? try
select unique zh from tab into temp tmpzh;
select a.* from tab a,tmpzh b
wherea.zh = b.zh and rq = ( select max( rq ) from tab where zh = b.zh ) ; select tb1.fse
from tbname tb1
where tb1.rq=(select max(tb2.rq) from tbname tb2 where tb1.zh=tb2.zh)
这样应该可以吧
select zh, max(rq) as maxrq
from tab
group by zh
into temp tab_tmp ;
select a.zh, a.rq, a.fse
from tab a, tab_tmp b
where a.zh = b.zh
and a.rq = b.maxrq ;
页:
[1]