以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]查询时distinct的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=100226)

--  作者:katent
--  发布时间:2017/5/7 13:24:00
--  [求助]查询时distinct的问题
是这样的,
我创建了一个查询表查询A,B,C字段,根据A不同B,C可以有相同的重复值,比如:
A  B  C
1  2  3
2  2  3
3  2  3

在窗口中只显示B,C字段,但可以用A字段去like查询,
这时我怎么能保证B,C不显示重复数据?

窗口的Table控件好像没有distnict属性

--  作者:有点色
--  发布时间:2017/5/7 16:19:00
--  

 把重复的剔除

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列,第三列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"