Datatable group by count 가 궁급합니다

dt_제조사결과시트
[CHILD_ITEM_CD,BP_NM
TDW , sung
TDW , sung
TDW , sungho
TDW , sung
TDW , sung
]
예를 들이 이런 데이터 테이블이 존재한다면

sung 4 , sungho 1
이런 구조로 DATATABLE을 변경할 수 있을까요 ?

@yundw Excel에서 헤더와 함께 원하는 출력 형식을 보여줄 수 있습니까?

image

그냥 심플하게 이런 구조의 한줄 데이터로 바꾸기만하면 됩니다

아 BP_NM이라는 컬럼의 데이터는 유동데이터입니다…

안녕하세요, @yundw 님.

Sung(4), sunho(1) 의 결과물만 나오면 되는건가요?

DT.Select(“[BP_NM]=‘sung’”).toDataTable.Rows.Count

BP_NM 컬럼의 값이 sung 인 것들만 모아 DT를 만들었을때의 Row 갯수
즉 sung의 갯수 입니다.

그렇다면 출력할때는

“sungho(” + DT.Select(“[BP_NM]=‘sung’”).toDataTable.Rows.Count.toString + “)”

이런 식으로 할 수 있지 않을까요?

나머지는 동일합니다.

도움이 되었으면 좋겠습니다.

3 Likes

@yundw
이 워크 플로를 확인할 수 있습니까?
출력은 문자열 형태이며 데이터 테이블이 아닙니다.
GroupByCountAndConcatenate.zip (7.6 KB)

@supermanPunch
How did you include “AsEnumerable()” extension Method?
I created new project then fallow your solution (not copy & paste).

it export error message like this.
‘AsEnumerable’ is not a member of ‘System.Data.DataTable’.

@ddochea You can Check this post to solve that :sweat_smile: :

1 Like

Thanks a lot!
I solved it :grinning:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.