日期:2014-05-17  浏览次数:20686 次

求高手给条sql 啊!!!!!!


有以上数据,要求返回 根据coupon_xuhao字段 最新的一条记录

即:





------解决方案--------------------
探讨

SQL code
select * from xxx x1 where coupon_date = (select max(coupon_date) from xxx x2 where x1.coupon_id = x2.coupon_id group by coupon_xuhao );

------解决方案--------------------
where x1.coupon_xuhao = x2.coupon_xuhao group by coupon_xuhao
明显这个group by 是没用的。