Bosch Building Technologies uses binary sensor readings from building automation systems to monitor equipment states. Write a PostgreSQL query that counts how often readings with values 0 and 1 occur for each building with at least one active device.
Requirements
- Join active devices to their sensor readings.
- Count readings equal to
0 and readings equal to 1 separately for each building.
- Include active buildings whose devices have no readings, returning zero counts where appropriate.
- Ignore
NULL readings and values other than 0 or 1, and sort the results alphabetically by building name.