SELECT b.largedivisionid AS large_division_name, MAX(b.NAME1) AS small_division_name,
       MAX(b.NAME2) AS small_division_name, MAX(b.NAME3) AS small_division_name, MAX(b.NAME4) AS small_division_name
FROM
(
 SELECT largedivisionid,
  CASE WHEN NAME = '학원/교육기관' THEN NAME END AS NAME1,
  CASE WHEN NAME = '유아용품점' THEN NAME END AS NAME2,
  CASE WHEN NAME = '온라인강의' THEN NAME END AS NAME3,
  CASE WHEN NAME = '기타' THEN NAME END AS NAME4
 FROM
 (
  SELECT largedivisionid, NAME
  FROM smalldivision
 ) a
) b
WHERE b.largedivisionid = 'LD00000002'
;

'Technology > Database' 카테고리의 다른 글

MySQL / Create table  (0) 2009.11.09
MySQL / MySQL 최적화 작업  (0) 2009.10.30
MySQL / Index 사용방법  (0) 2009.10.22
MySQL / 명령어 정리  (0) 2009.10.22
MySQL / 대용량 파일을 손쉽게 Insert 하기. (load data)  (0) 2009.10.22

+ Recent posts