日期:2014-05-16 浏览次数:20912 次
SELECT id, name AS new_name, date, ( SELECT count( * ) FROM test1 WHERE name = new_name )sum FROM test1 ORDER BY name
------解决方案--------------------
SELECT id, NAME AS name1, DATE,(SELECT COUNT(NAME) FROM tb WHERE NAME = name1) AS SUM FROM tb ORDER BY NAME DESC,DATE DESC;
------解决方案--------------------
select * from table1 a order by (select max(date) from table1 where name=a.name)
------解决方案--------------------
SELECT *,(SELECT COUNT(*) FROM ttl WHERE a.`name`=`name` ) AS `sum`
?FROM ttl a
ORDER BY FIND_IN_SET(a.`name`,'d,c,a,b'),a.`date` DESC