Given following table A
FlightID| Roles 1 | Pilot 1 | Steward 1 | Steward 2 | Pilot 2 | Co-Pilot How can I determine the number of stewards on each distinct flight? The output should be like this:
FlightID| Count 1 | 2 2 | 0 First I tried:
select FlightID, count(Role) from A group by FlightID but this gives me the total number of roles per flight. Then I tried:
select FlightID, count(Role) from A where Role="Steward" group by FlightID this is partially right since it gives me the number of stewards per flight, but it does not take into account 0 stewards. How can I also include 0 stewards into the result?