• 쇼핑몰
  • 커뮤니티
  • 북마크

vb.net


[Controls] [vb.net] DataTable Count / Sum / Distinct

하나를하더라도최선을
2021.05.02 10:44 391 0

본문



'// 정렬 후 유일한 값 추출

 
Dim DA() As String = D.Select("""testPaperNum ASC").CopyToDataTable.AsEnumerable().Select(Function(DR)
                                        Return DR.Field(Of Long)("testPaperNum").ToString
                                    End Function).Distinct().ToArray
 
 
 
 
'// 특정 조건 데이터 갯수
 
Count = D.Select(String.Format("[testPaperNum]='{0}' AND [Difficulty]='{1}' AND [correct]='{2}'", DA, DB, 0)).Length
 
또는
 
Count = D.Compute("count(testPaperNum)"String.Format("[testPaperNum]='{0}' AND [Difficulty]='{1}' AND [correct]='{2}'", DA, DB, 0))
 
 
 
 
 
'// 조건에 부합하는 합계
 
sum = Convert.ToInt32(getCellValue(D.Compute("SUM(Scored)"String.Format("[testPaperNum]='{0}' AND [Difficulty]='{1}' AND [correct]='{2}'", DA, DB, 0))))
[이 게시물은 하나를하더라도최선을님에 의해 2021-05-02 10:45:10 C#에서 이동 됨]


댓글목록 0

등록된 댓글이 없습니다.