Ashraf Misran
Ashraf Misran

Reputation: 73

Count different values in single column and show in their respective column using Access

I have a set of data of cars as follow:

| class |  car  |
|  S    | Hilux |
|  M    | Hilux |
|  M    | Toyota|
|  M    | Hilux |
|  S    | toyota|
|  S    | toyota|
|  L    | toyota|

And I want to show as per below:

| class | Hilux | Toyota |
|   S   |   1   |   2    |
|   M   |   2   |   1    |
|   L   |   0   |   1    |

How can it be done using Ms Access?

Upvotes: 0

Views: 30

Answers (1)

Nishant Gupta
Nishant Gupta

Reputation: 3656

This might work:

TRANSFORM COUNT(car)
SELECT class
FROM Table_name
GROUP BY class
PIVOT car;

Upvotes: 1

Related Questions