sql查重去除id最小值
select order_id FROM yzj_store_order t WHERE (t.user_id,t.order_status) IN ( SELECT user_id,order_status FROM yzj_store_order where order_status=0 AND DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( CURDATE( ) - 0, '%Y-%m-%d' ) GROUP BY user_id,order_status HAVING count( * ) > 1 ) AND DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( CURDATE( ) - 0, '%Y-%m-%d' ) AND id NOT IN ( SELECT min( id ) FROM yzj_store_order WHERE DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( CURDATE( ) - 0, '%Y-%m-%d' ) and order_status=0 GROUP BY user_id,order_status HAVING count( * ) > 1 ) ORDER BY user_id desc select order_id FROM yzj_store_order t WHERE (t.user_id,t.order_status) IN ( SELECT user_id,order_status FROM yzj_store_order where order_status=1 AND DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( CURDATE( ) - 0, '%Y-%m-%d' ) GROUP BY user_id,order_status HAVING count( * ) > 1 ) AND DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( CURDATE( ) - 0, '%Y-%m-%d' ) AND id NOT IN ( SELECT min( id ) FROM yzj_store_order WHERE DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( CURDATE( ) - 0, '%Y-%m-%d' ) and order_status=1 GROUP BY user_id,order_status HAVING count( * ) > 1 ) ORDER BY user_id desc
sql查重重保留最小值