Building capacity

Question

Suppose you have the following tables containing information about the buildings a company occupies as well as employee building assignments. Capacity in the "building_info" table refers to the number of employees a given building can seat.

building_info

building_id location building_name capacity
00001 New York US-NY-01 50
00002 Los Angeles US-LA-01 100
00003 Tokyo JP-TK-01 200
00004 Detroit US-DT-01 100
00005 London UK-LN-01 350
... ... ... ...

building_assignments

employee_id employee_name building_id
31331 Beth 00001
34611 Tim 00001
49760 Susan 00003
26583 Jim 00004
20267 Lin 00005
... ... ...

Using the tables above, write a SQL query to return the building_id, building_name, number of empty seats, and the percent of seats occupied for each unique building.

Your output should return the columns listed below and each row in the table should represent a single building.

building_id building_name seats_empty pct_seats_full
A B C D
E F G H

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now