field 发表于 2007-04-19 11:15

请教一个关于informix语句的问题

情况是这样的,有一个表有以下字段:
zh,fse,rq
其中有很多记录zh字段是相同的,我只想取出其中rq最大的那条记录的fse,请教这个语句如何写?

wenlq 发表于 2007-04-19 12:29

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 ) ;

shanshl 发表于 2007-04-19 16:26

select tb1.fse
from tbname tb1
where tb1.rq=(select max(tb2.rq) from tbname tb2 where tb1.zh=tb2.zh)
这样应该可以吧

john_student 发表于 2007-04-22 13:20


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]
查看完整版本: 请教一个关于informix语句的问题