当前位置: 代码迷 >> Java Web开发 >> 求好手给条sql 啊
  详细解决方案

求好手给条sql 啊

热度:9336   发布时间:2013-02-25 21:17:30.0
求高手给条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 是没用的。
  相关解决方案