Mysql ORDER BY COUNT(*)获取最旧的行

时间:2015-07-04 10:29:47

标签: php mysql group-by sql-order-by

你能帮帮我吗?我想

1)检查来自tb_pre_sale的id是否在列seler_0上不存在或者是否存在但至少重复2次

2)获取最老的

谢谢!

 SELECT DISTINCT seller_0 
 FROM tb_pre_sale 
 WHERE seller_0 !=? 
 GROUP BY id 
 ORDER BY COUNT(*) < ? DESC

1 个答案:

答案 0 :(得分:0)

 SELECT seller_0 
 FROM tb_pre_sale 
 WHERE seller_0 !=? 
 GROUP BY  seller_0 
 HAVING COUNT(*) < ? ORDER BY seller_0 DESC