0
내 표 - 교육CONCAT 2 열 데이터 (기준 그룹)
State Code Descr
AA 001 aaaaaa
AA 002 aaaabbb
BB 003 qwerty
CC 025 asdfg
BB 014 zsedc
AA 015 lknhj
CC 084 uhygt
CC 067 fdrda
나는 그것이 형식 아래에서 원하는 :
국가 코드 내가 노력하고 succeded하고
AA 001-aaaaaa,002-aaaabbb,015-lknhj
BB 003-qwerty,014-zsedc**
CC 025-asdfg,084-uhygt,067-fdrda
아래의 쿼리로 단일 행의 '코드'열을 가져 오는 중 :
select state,
replace(wm_concat(code), ',', ',') CODE
from education
group by state
order by state;
출력 :
State Code
AA 001,002,015
BB 003,014
CC 025,084,067
그리고 또한 내가 쿼리 아래를 통해 각 code
에 대한 descr
각각 가지고있다 :
select state, concat(concat(replace(wm_concat(code),',',','), '-'),descr) CODE
from education
group by state,descr
order by state
당신이 원하는 출력을 얻기 위해 클럽까지 쿼리 나에게 도움이 될 수 있습니다.
미리 감사드립니다.
당신을 감사 할 수 있습니다! !!!! 또한 작업 코드 아래에 있습니다. 상태 선택, wm_concat (concat (concat (code, '-'), descr)) 상태 별 교육 그룹 별 CODE – user3360094