Count of same row

Posted on 2014-08-21
Last Modified: 2014-08-21

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


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)
Question by:GIP
    LVL 21

    Accepted Solution

    Well you can query the table via SQL:
    Select city,count(city) from yourtable group by city

    Open in new window

    LVL 25

    Expert Comment

    by:Shaun Kline
    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:

    Author Comment

    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


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now