简体   繁体   中英

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?

This might work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM