2013. 10. 23. 14:30
DB/MySQL
http://jan.kneschke.de/projects/mysql/groupwise-max/
아래와 같은 방법도 있다...
SELECT continent,
SUBSTRING( MAX( CONCAT(LPAD(population,10,'0'),name) ), 10+1) AS name,
MAX( population ) AS population
FROM Country
GROUP BY continent;
SELECT continent,
SUBSTRING_INDEX(GROUP_CONCAT(name ORDER BY population, ','), ',', 1)) AS name,
MAX( population ) AS population
FROM Country
GROUP BY continent;
'DB > MySQL' 카테고리의 다른 글
INSERT IGNORE (0) | 2013.11.29 |
---|---|
procedure function 덤프 (0) | 2013.10.31 |
datadir 변경에 대한 답변 (0) | 2013.09.25 |
SELECT 결과 INSERT하기 (0) | 2013.09.12 |
last_insert_id() (0) | 2013.09.11 |