Home > front end >  How to Select Distinct records then count them in C# Access database?
How to Select Distinct records then count them in C# Access database?

Time:05-31

I have a table called TableA

Table A

I want my results to be like this

Results

My code

       string query = "Select Column2,Count(*) from (Select DISTINCT Column1 from TableA Group by Column2)"

I have tried a lot of solutions for apparently simple task but in vain. Been stuck from couple of hours. wish Access 2007 allow a simple Count(Distinct Column1) etc but it doesn't. Help and guidance is required.

CodePudding user response:

SELECT Count(*) FROM (SELECT Distinct column1 FROM TableA GROUP BY column2);

CodePudding user response:

From the results screenshot I think you are looking for

SELECT COUNT(DISTINCT column1) FROM TableA
GROUP BY column2;
  • Related