I've got the following table in SQL Server:
| ExperienceId | EmployeeId | ExperienceType |
|---|---|---|
| 1 | 1 | 'Work' |
| 2 | 1 | 'Internal' |
| 3 | 2 | 'Internal' |
| 4 | 3 | 'External' |
| 5 | 3 | 'External' |
There are only 3 possible values of ExperienceType: 'Work', 'Internal' and 'External'
I'd like to know how many experiences of each type has each employee:
| EmployeeId | Work exp | Internal exp | External exp |
|---|---|---|---|
| 1 | 1 | 1 | 0 |
| 2 | 0 | 1 | 0 |
| 3 | 0 | 0 | 2 |
I've tried this
select EmployeeId, count(*)
from EmployeeExperiences
group by EmployeeId
But that only gives me the total number of experiences per employee, and I don't know how to disaggregate that by ExperienceType.