• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 110
  • Last Modified:

Count of same row

Hi,

I want to know if there are function to return count of the same row data in DataTable

Example

City, Name
New York, Paul
Boston, Catherine
New York, Cathy
New York, Debby

I want the number of city
In this example, the answer is two (New York, Boston)
0
GIP
Asked:
GIP
1 Solution
 
Randy PooleCommented:
Well you can query the table via SQL:
Select city,count(city) from yourtable group by city

Open in new window

0
 
Shaun KlineLead Software EngineerCommented:
You can use the DataView.ToTable() function.
This link is to the overload that will only add distinct values to the new table based on the selected columns:
http://msdn.microsoft.com/en-us/library/wec2b2e6(v=vs.110).aspx
0
 
GIPAuthor Commented:
I decided to use a second table in my SQL query to return my value

Shaune thank you for your answer too.

SELECT COUNT(Distinct NomFamille) From #TempCommandeExcel

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now