I am new to SQL and am having trouble using the count function to determine how many 'YES' or 'NO' for each criteria - apologies, this may be a stupid question.
I have a table with data like this (there are more businesstravel categories):
| attrition | businesstravel |
|---|---|
| Yes | Travel_Rarely |
| No | Travel_Frequently |
| Yes | Travel_Rarely |
| No | Travel_Frequently |
| No | Travel_Rarely |
And I want to count how many 'Yes' and 'No's align to each of the businesstravel categories. For example, like the below:
| attrition | businesstravel | count |
|---|---|---|
| Yes | Travel_Rarely | 43 |
| No | Travel_Rarely | 65 |
| Yes | Travel_Frequently | 72 |
| No | Travel_Frequently | 5 |
I have tried the below but no luck:
- SELECT businesstravel, attrition
- COUNT(attrition)
- FROM wa_fn_usec_hr_employee_attrition_tsv
- GROUP BY businesstravel;