Filter by Count in DataSet

S

Stuart Shay

Hello All:



I have a Dataset that is built from the following query



USE Northwind

SELECT * FROM Orders

ORDER BY Customer



I want to filter in the dataset for Customers that have >10 purchase
orders.



How Can I apply such logic in a DataView.



Thanks

Stuart
 
C

Cor Ligthert

Stuart,

The only one I see is this. Be aware that I did not test it.

\\\
Public Function distinct(ByVal dt As DataTable, _
ByVal distinct value As String) As DataTable
Dim dtclone As DataTable = dt.Clone
Dim dv As New DataView(dt)
dv.Sort = dist
Dim myselold As String = ""
dim y as integer
For i As Integer = 0 To dv.Count - 1
y += 1
If myselold <> dv(i)(dist).ToString Then
Dim drn As DataRow = dtclone.NewRow
For y As Integer = 0 To drn.ItemArray.Length - 1
drn(y) = dv(i)(y)
Next
myselold = dv(i)(dist).ToString
if y > 9 then
dtclone.Rows.Add(drn)
end if
y = 0
End If
Next
Return dtclone
End Function
////

I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top