블로그 이미지
암초보

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Notice

Tag

04-28 16:36
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
posted by 암초보