oracle 去ID最大的那条记录
select m.name,m.merchant_id,c.*
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text'
这样查出来是 多条数据! 如何取出 m.merchant_id 最大的那条记录
------解决方案--------------------select ROWNUM,m.name,m.merchant_id,c.*
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text' AND ROWNUM = 1
ORDER BY m.merchant_id DESC
------解决方案--------------------
select rownum,t.* from
(select m.name,m.merchant_id,c.*
from couponinfo c,merchant m, coupon_merchant cm
where c.coupon_id=cm.product_id
and cm.merchant_id=m.merchant_id
and c.coupon_name = 'text'
order by m.merchant_id desc) t
where rownum=1;
没数据就没试,不知道行不行,你试试