select *
from prpdexch
where exchdate = (select max(exchdate)
from prpdexch
where basecurrency = 'HKD'
and exchcurrency = 'CNY'
and validstatus = '1')
and basecurrency = 'HKD'
and exchcurrency = 'CNY'
and validstatus = '1'
一张兑换率表,里面存放的是各种货币之间的兑换率关系。我想查离当前时间最近的一条兑换率信息。于是就写了上面的语句。虽然可以查询出来。但是这种写法我自己都觉得纠结。
请问有没有可以精简的写法呢。谢谢各位了!
(select *
from prpdexch
where basecurrency = 'HKD'
and exchcurrency = 'CNY'
and validstatus = '1'
order by exchdate desc)
where rownum=1
(SELECT * FROM prpdexch
WHERE basecurrency = 'HKD'
AND exchcurrency = 'CNY'
AND validstatus = '1'
ORDER BY exchdate DESC)
WHERE ROWNUM = 1;